in reply to Parallel::ForkManager and wait_all_children
Another way to do it, at the expense of having twice-as-many child processes, is to initially fork a child which sets an alarm and then forks the actual child. If the alarm goes off, this process kills its child and then exits (with a return-code of 1). It does nothing else but to wait, either for its child to exit or for the alarm to go off.
The way I saw it done was with a small command: timed_exec -t timeout command. That’s what the parent-process actually executed and waited-for. But it was such a handy thing that I saw it being used in a lot of shell-scripts, too.
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parallel::ForkManager and wait_all_children
by ikegami (Patriarch) on May 13, 2015 at 22:02 UTC |