http://www.perlmonks.org?node_id=1036141


in reply to Parallel::ForkManager leaves a zombie process from last child

anyway, this seems to work better
while (1) { $pm->start and next; while ($inputcon = $daemon->accept()) { do_client_stuff($inputcon); } $pm->finish(); }
it reuses processes and I don't see zombies.

Replies are listed 'Best First'.
Re^2: Parallel::ForkManager leaves a zombie process from last child
by ikegami (Patriarch) on Jun 01, 2013 at 23:15 UTC

    You find 1 yet-to-be reaped process wasteful, but you're ok with having N blocked processes??? I don't think you know what you want!!!

    That said, this is a better solution. You fork *before* a connection comes in, so there's less lag in handling a response. And since you reuse the child process, you don't waste time forking repeatedly. One might wonder why P::FM is used at all, but it causes children that die for whatever reason to be restarted, so you always have a full pool of children waiting!

A reply falls below the community's threshold of quality. You may see it by logging in.