in reply to Re^3: Parallel::ForkManager run_on_finish exit code handler
in thread Parallel::ForkManager run_on_finish exit code handler
ikegami - Thanks. The following code works.
for my $host (@hosts) { $pm->start($host) and next; exec(@some_command); print(STDERR "exec failed: $!\n"); _exit($!); }
The database connection is now persistent in run_on_finish(), and I am able to insert the return code into the db from the callback routine.
Thinking of the Chinese proverb.. give a man a fish.. teach a man to fish.. Rather than me just blindly accepting the code improvement, can you explain how run_on_finish() gets the return code without having $return_code passed in as either $pm->finish($return_code) or _exit($return_code) ?
Also, why is 'exec' preferred over 'system + _exit' ? I thought exec executes a system command and never returns.. I am surprised that this works actually.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Parallel::ForkManager run_on_finish exit code handler
by ikegami (Patriarch) on Sep 09, 2009 at 00:25 UTC |