http://qs1969.pair.com?node_id=1172978


in reply to eval system timeout child process

If your problem is with zombie processes, then you should simply do waiting for your child process. There's such function 'wait' or 'waitpid'. In general, if you start child process and then don't do 'wait' on it, then that process after termination shall become 'zombie'. Zombies disappear when their parents finish their work. An alternative to calling 'wait' is to put $SIG{CHLD}="IGNORE"; indicating, that you are not interested in the status of child processes.

From your code it is not clear where do you get the $child_pid from. Generally, the 'system' call does 'wait' for child. When you abort 'system' via ALRM signal, that waiting does not happen, so you get zombie. I don't know if setting SIG{CHLD} would affect 'system' functionality. Alternatively, you can call 'waitpid(-1, WNOHANG)' after you detected that alarm has happened.