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: 0 comes back, iconic, slay πŸ’–
  • on error: -1 comes back AND errno gets set to tell you what went wrong. classic.

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” sig is 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, see kill(2) πŸ™ˆ
  • ESRCH β€” no process can be found in the process group specified by pgrp. empty group, empty vibes, nobody home πŸ¦‹
  • ESRCH β€” the process group was given as 0 but 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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms