Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

raise, kill, killpg (and the tgkill wrapper underneath) - glibc

Split from the chapter glibc: Process, Threads and Signals into the per-function layout; see the method page and the glibc ledger for coverage status.

FieldValue
IDGLIBC-raise, GLIBC-kill, GLIBC-killpg, GLIBC-tgkill, GLIBC-gsignal
Headersignal.h (raise ungated; kill under __USE_POSIX; killpg, gsignal under __USE_MISC/XOPEN; tgkill under __USE_GNU)
Provenanceraise: ISO C; kill: POSIX.1; killpg: BSD; tgkill: Linux (manual)
Exportedraise and gsignal alias one address @@GLIBC_2.2.5; kill/killpg @@GLIBC_2.2.5; tgkill @@GLIBC_2.30 (nm)
Thread-safetyMT-Safe / AS-safe (manual safety notes)
Wrapsraise uses tgkill(2); killpg calls kill(-pgid, sig) (manual comment)
Statusdocumented

Semantics – raise(sig) signals the caller: single-threaded it equals kill(getpid(), sig); multithreaded it equals pthread_kill(pthread_self(), sig) (raise.3), i.e. it is thread-directed. kill(pid, sig) is process/group-directed: pid > 0 one process (on Linux the whole process even if a TID is passed), 0 the caller’s process group, -1 all permitted processes, < -1 process group -pid; sig == 0 probes for existence (manual, Signaling Another Process). kill succeeds if at least one target got the signal; errors EINVAL/EPERM/ESRCH. Permission: sender privileged, or real/effective UID match; SIGCONT may cross within one session (manual). killpg sends to process group pgid; pgid == 0 means the caller’s group (killpg.3).

Gotchas and portability – since glibc 2.3.3 raise is tgkill with the caller’s TID (raise.3 NOTES); musl’s raise.c uses tkill the same way, and its killpg rejects negative pgid with EINVAL.

References – raise(3), kill(2), killpg(3); manual Signaling Yourself / Signaling Another Process nodes; syscall view: kill, tgkill.