Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why is setting the signal handler for SIGHUP to getpid preferable to masking the signal?


> But when we exec a child, the kernel resets any signal not set to `SIG_IGN` to `SIG_DFL`, so all our children, atomically, get their `SIGCHLD` handlers set to `SIG_DFL` at the moment of creation. Consequently, when either our process or the kernel sends `SIGHUP` to our process group, all our children die.


SIG_IGN is not the same as the signal mask.

The result is the same though; I forgot that signal mask is not reset on exec. Damn POSIX signals!




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: