Linux: Why won't my child processes quit completely?

Another dumb Linux question to ask: Why won’t the fork()ed processes I create completely quit when I’m done?

I have a matching client/server application I wrote, which routes data from a serial port to a socket attached to another serial port. In both cases the parent waits for data to appear, fork()s, and the child does what it needs to do, then exit()s.
When I do $ ps -ef, I see all of those child processes in the list surrounded by . They won’t go away until the parent process that spawned then is killed. I do not observe this when I’m debugging (via GDB/GDBSERVER).

Is this normal behavior? If not, what am I doing wrong? Will a proliferation of moribund child processes eventually crash the system?

Did you properly wait for the exit status in the parent? If not, you’ve most likely got zombies.
Brrraaaaaaaaaaains.

That’s it. Now I gotta figure out how to handle SIGCHLD. I don’t want to wait(), because I can get another message to be processed in the meantime.

If the Wikipedia page is to be believed, doing a “signal(SIGCHILD, SIG_IGN);” prior to spawning off the processes will get rid of the zombies.

ETA: Another option is to spawn off a different process that will spawn off your child processes; the only point to this new process is to spawn its children and then exit, meaning that the child processes will be inherited by init, which waits on its children properly.

I found the reference on the Wikipedia page, implemented it, and it works. No more zombies.

If only it were that easy here. I’m down to using a spade.

Damn zombies. :wink:

Si