[TUHS] fork

Warren Toomey via TUHS tuhs at tuhs.org
Tue May 12 18:39:38 AEST 2026


On Tue, May 12, 2026 at 10:19:25AM +0200, Folkert van Heusden via TUHS 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?

I'm going to take an educated guess. You fork() a child, but in the
parent process you never wait()? Thus, once the child exit()s, no
process collects the exit status and so the child becomes a zombie
process. Eventually the init process will reap your child's exit status.

signal(SIGCHLD, SIG_IGN) is only going to make the parent ignore any
change to the child's status; it doesn't take the child out of the
process table. Technically (I believe), the child's memory and other
resources are freed when it exit(s), but the process-id, the exit status
and the slot in the process table stay there until someone wait(s).

Cheers, Warren


More information about the TUHS mailing list