KILLPG(2)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… KILLPG(2) β€” the process-group group chat

okay so bestie, this is killpg from section 2 of the manual β€” the System Calls Manual, no big deal. it's the one that lets you yell at a whole squad of processes at once instead of DMing them one by one. iconic behavior tbh πŸŽ€


✨ NAME ✨

killpg β€” send a signal to a process group. that's it, that's the whole vibe. one signal, whole group, done. πŸ¦‹


πŸ“š LIBRARY πŸ“š

Standard C Library, aka libc, and you link it with -lc. the standard-est. 🫢


🌸 SYNOPSIS 🌸

#include <sys/types.h>
#include <signal.h>

int
killpg(pid_t pgrp, int sig);

like, you include both headers, bestie, don't skip one and then come crying to me 😭


πŸ’œ DESCRIPTION πŸ’œ

so the way that killpg() works is: it sends the signal sig to the process group pgrp. that's the whole function. very demure, very mindful.

wanna know which signals exist? go look at sigaction(2), it has the whole list β€” I'm not retyping all of them, that's a whole other manpage πŸ’€

and here's the cute little special case: if pgrp is 0, killpg() sends the signal to the sending process's own process group. so it's like, "signal me and my friends," and you are one of the friends. main character energy fr fr πŸ‘‘

one thing though β€” the sending process must be able to kill() at least one process in the receiving process group. that's the permission check. you don't need perms on everybody, just one of them. generous of the kernel honestly πŸ’…


πŸ¦‹ RETURN VALUES πŸ¦‹

  • returns the value 0 if it worked. slay. ✨
  • otherwise it returns the value -1, and the global variable errno gets set to tell you why. so check errno, bestie, it's literally right there πŸ™ˆ

πŸ”₯ ERRORS πŸ”₯

if any of these happen, killpg() fails and no signal is sent β€” like, no signal will be sent at all, not even a partial one. periodt.

  • [EINVAL] β€” the sig argument is not a valid signal number. you made one up. the kernel said no. πŸ’€
  • [ESRCH] β€” no process can be found in the process group specified by pgrp. the group chat is empty, nobody's home, ghost town. 😭
  • [EPERM] β€” kill() returns EPERM for all processes in the process group. you got no perms on anyone in that squad. rough. 🚫

🧚 SEE ALSO 🧚

go read those too, they're the supporting cast and they ate πŸ”₯


⭐ HISTORY ⭐

the killpg() function appeared in 4.0BSD. yeah, she's old money. vintage icon. 🌈


ngl the one thing to actually remember: 0 as pgrp means your own process group, and you only need kill() permission on one member of the target group. everything else is just vibes and errno.

okay that's the whole page, you're officially a process-group menace now πŸ“ stay hydrated, check your return values, and remember: this is the Debian build, dated March 15, 2012 β€” so like, she's been serving this exact look for a minute. mwah πŸ’–πŸ§šβ€β™€οΈ

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms