swaroop has asked for the wisdom of the Perl Monks concerning the following question:
-----------------------------------------------------------my $fork_retry = 10; my $timelimit = 86400; my $signal = 0; my $pid; local $SIG{'CHLD'} = 'IGNORE'; FORK: { if ( $pid = fork ) { return($pid); } else { die "cannot fork: $!" unless defined $pid; open(STDOUT,"> $logfile.out"); open(STDERR,"> $logfile.err"); local $SIG{'INT'} = "IGNORE"; alarm $timelimit; # set the timeout exec ("$cmd"); die "Unable to exec $cmd : @_\n"; } warn "Unable to fork"."Retrying in $fork_retry seconds.\n"; sleep $fork_retry; redo FORK; }
20060131 Janitored by Corion: Moved code into code tags
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
| A reply falls below the community's threshold of quality. You may see it by logging in. | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |