PR_SET_PDEATHSIG(2const)

πŸ’– PR_SET_PDEATHSIG πŸ’–

okay bestie, welcome to PR_SET_PDEATHSIG(2const) β€” it's a Linux thing, it lives in the prctl family, and it's honestly giving "your parent died so here's a signal, no cap". let's get into it 🫢


✨ NAME ✨

PR_SET_PDEATHSIG β€” set the parent-death signal of the calling process πŸŽ€


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) β€” the classic, the icon, the one you already have πŸ’…


🌸 SYNOPSIS 🌸

#include <linux/prctl.h>  /* Definition of PR_* constants */
#include <sys/prctl.h>

int prctl(PR_SET_PDEATHSIG, long sig);

πŸ’« DESCRIPTION πŸ’«

so basically, this sets the parent-death signal of the calling process to sig. and sig can be either a signal value in the range [1, NSIG - 1], or 0 to clear the whole thing. this is, literally, the signal that the calling process will get when its parent dies 😭

the parent-death signal gets sent upon subsequent termination of the parent thread, and also upon termination of each subreaper process (peep PR_SET_CHILD_SUBREAPER(2const)) to which the caller is subsequently reparented. and if the parent thread and all ancestor subreapers have already terminated by the time of the PR_SET_PDEATHSIG operation? then no parent-death signal is sent to the caller. nothing. radio silence. periodt πŸ’€

the parent-death signal is process-directed (see signal(7)), and if the child installs a handler using the sigaction(2) SA_SIGINFO flag, then the si_pid field of the siginfo_t argument of the handler contains the PID of the terminating parent process. like, the receipts are right there in the struct πŸ‘‘

now the part you gotta remember or you WILL get got: the parent-death signal setting is cleared for the child of a fork(2). it's also (since Linux 2.4.36 / 2.6.23) cleared when executing a set-user-ID or set-group-ID binary, or a binary that has associated capabilities (see capabilities(7)); otherwise, this value is preserved across execve(2). and it ALSO gets cleared upon changes to any of these thread credentials: effective user ID, effective group ID, filesystem user ID, or filesystem group ID. so many little ways to lose it, bestie, stay woke 🌈


πŸ”₯ RETURN VALUE πŸ”₯

  • On success, 0 is returned πŸ₯³
  • On error, -1 is returned, and errno is set to indicate the error πŸ™ˆ

πŸ’€ ERRORS πŸ’€

  • EINVAL β€” sig is not a valid signal number. not a vibe. fix it.

πŸ‘‘ STANDARDS πŸ‘‘

Linux. that's it, that's the whole section. main character energy only πŸ’œ


πŸ¦‹ HISTORY πŸ¦‹

Linux 2.1.57 β€” an elder, an ancestor, iconic since day one ⭐


⚠️ CAVEATS ⚠️

okay this is the important one, read it twice πŸ’–

the "parent" in this case is considered to be the thread that created this process. in other words? the signal will be sent when that thread terminates (via, for example, pthread_exit(3)), rather than after all of the threads in the parent process terminate. so it's not "the whole parent process is gone" β€” it's "that specific thread dipped" 😭 ngl this trips people up every single time.


πŸŽ€ SEE ALSO πŸŽ€


that's the whole page bestie, go forth and set your parent-death signals responsibly πŸ’…βœ¨

signing off with love β€” this was the Linux man-pages version 6.20, dated 2026-02-08, for PR_SET_PDEATHSIG(2const) 🫢🌸

πŸ“¦ 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: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms