unlinker has asked for the wisdom of the Perl Monks concerning the following question:
Since the loop (ideally) goes on forever, I have no opportunity to make the cleanup call:while (1) { $pm->start and next; ... # do child tasks here ... $pm->finish; }
In such a situation, should I write a run_on_finish callback that calls waitpid on the exited process like this:$pm->wait_all_children;
Is there a better way to clean up than this? Thank you for your attention.$pmgr->run_on_finish( sub { my ($pid, $exit_code, $ident) = @_; waitpid $pid, 0; } );
|
|---|