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?
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.