swaroop has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,

I'm getting the following error while forking the process using the fork n exec.

kernel: application bug: script1(17668) has SIGCHLD set to SIG_IGN but calls wait().
kernel: (see the NOTES section of 'man 2 wait'). Workaround activated.

Here is the code I'm using for forking process.

* Ignore child.
* Fork the process.
* Send STDOUT/STDERR to files.

-----------------------------------------------------------
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; }
-----------------------------------------------------------

Thanks.

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.