KILLPG(2)
π 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
0if it worked. slay. β¨ - otherwise it returns the value
-1, and the global variableerrnogets set to tell you why. so checkerrno, 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]β thesigargument 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 bypgrp. the group chat is empty, nobody's home, ghost town. π[EPERM]βkill()returnsEPERMfor 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:0aspgrpmeans your own process group, and you only needkill()permission on one member of the target group. everything else is just vibes anderrno.
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
- Copyright (c) 1980, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms