killpg(3)
β¨ killpg β bestie edition β¨
okay so quick vibe check: this is the killpg page from section 3 of the manual, aka the library functions girlies. it lives in the Standard C library (libc, -lc) π and it's literally just "hey, go yeet a signal at a whole process group." no cap.
πΈ NAME πΈ
killpg β send signal to a process group π
π LIBRARY π
Standard C library (libc, -lc) π«Ά
β¨ SYNOPSIS β¨
#include <signal.h>
int killpg(int pgrp, int sig);
π§ Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
killpg():_XOPEN_SOURCE >= 500|| /* Since glibc 2.19: */ _DEFAULT_SOURCE|| /* glibc <= 2.19: */ _BSD_SOURCE
like, yes bestie, you do gotta unlock it with one of those macros first. boss level requirements fr fr π
π DESCRIPTION π
so basically killpg() sends the signal sig to the process group pgrp π. wanna know what signals even are? go read signal(7), it has the whole list, it's giving encyclopedia.
if pgrp is 0, killpg() sends the signal to the calling process's own process group π«Ά. but POSIX says: if pgrp is less than or equal to 1, the behavior is undefined. so likeβ¦ don't. that's the cursed zone. π
also, if you're tryna send a signal to some other process, there's a whole permissions situation β the deets are in kill(2). go read it, i'm not summarizing it, that's not the assignment. π
π₯ RETURN VALUE π₯
- on success:
0comes back, iconic, slay π - on error:
-1comes back ANDerrnogets set to tell you what went wrong. classic.
π ERRORS π
EINVALβsigis not a valid signal number. like bestie that's not a signal, that's just a random number πEPERMβ the process does not have permission to send the signal to any of the target processes. for the required permissions, seekill(2)πESRCHβ no process can be found in the process group specified bypgrp. empty group, empty vibes, nobody home π¦ESRCHβ the process group was given as0but the sending process does not have a process group. yeah that one's rough, the call is coming from inside a process with no group, and it's undefined-coded π
β VERSIONS β
there are various differences between the permission checking in BSD-type systems and System V-type systems π. see the POSIX rationale for kill(3p) β it's giving lore, fr. and here's one difference that POSIX doesn't even mention: it's about the return value EPERM. BSD documents that no signal is sent and EPERM is returned when the permission check failed for at least one target process. POSIX documents EPERM only when the permission check failed for all target processes. so like, same error code, different main character energy depending on whose rules you're playing by π
π C library/kernel differences
on Linux, killpg() is implemented as a library function that makes the call kill(-pgrp, sig) β so it's basically a little wrapper bestie, a cute lil transformation that flips the sign and hands it to kill. periodt.
πΈ STANDARDS πΈ
POSIX.1-2008. β¨
π¦ HISTORY π¦
POSIX.1-2001, SVr4, 4.4BSD (first appeared in 4BSD). she's old but she ate and she's still here π
π«Ά SEE ALSO π«Ά
getpgrp(2), kill(2), signal(2), capabilities(7), credentials(7) β go read these, iykyk π
and that's the whole thing bestie, you're so welcome π this lil page is from Linux man-pages 6.20, dated 2025-05-17 β no cap, go forth and signal responsibly, mwah πβ¨
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: BSD-4-Clause-UC
- Copyright 1980-1991, Regents of the University of California
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms