I am trying to launch android emulator in perl using fork, exec. Afterwards I need to kill it too but killing it results in zombie processes with emulator running in background.

I've tried killing using kill -1 as well as kill -9 and killall -v emulator. I've also tried exec'ing by appending explicit exec("exec command ...") but either way I get a zombie process till the perl script is running.

2 Answers
2

You should use waitpid in parent process after killing the child process. That's because you use fork to get a new process, Perl wouldn't do the clean-up job for you as in system.
But I recommend a better module in CPAN which does the whole messy thing, I find it very convenient.