[TUHS] fork
Peter Jeremy via TUHS
tuhs at tuhs.org
Tue May 12 21:18:48 AEST 2026
On 2026-May-12 10:19:25 +0200, Folkert van Heusden via TUHS <tuhs at tuhs.org> wrote:
>Now something unexpected is happening: after a request, a "<defunct>" proces
>is left in the process list. Usually that is caused by a fork() not being
>join()ed afterwards. But in main() of httpdp I invoke signal(SIGCHLD,
>SIG_IGN); so I thought I took care of that?
For "modern" Unixes (e.g. FreeBSD and Linux), there's a SA_NOCLDWAIT flag
for sigaction(2) that explicitly says setting SIGCHLD to SIG_IGN means that
child processes will not become zombies but will instead be implicitly
reaped immediately.
This doesn't exist in BSD2.11 and, as far as I can tell from looking
through the sources, there's no equivalent behaviour: When a process exits,
the process becomes a zombie and the parent is sent a SIGCHLD (see
kern_exit.c::exit()). In psignal(), if a signal is marked SIG_IGN, the
signal is completely ignored - there's no special handling of SIGCHLD.
There's no obvious code to clean up zombie processes if the parent doesn't
wait() for them.
--
Peter Jeremy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://www.tuhs.org/pipermail/tuhs/attachments/20260512/accef5c0/attachment.sig>
More information about the TUHS
mailing list