jsoverson has asked for the wisdom of the Perl Monks concerning the following question:
$SIG{CHLD} = sub { }; while (1) { for(1..10) {spawn(\&foo)} # fork off 10 &foo()'s my $s = sleep (2); # $s will hold the number of # seconds actually slept print "--------------------"; if ($s) { print "Slept for $s seconds\n"; }# If we slept at all else { print "Did not sleep at all\n"; }# If we didn't } sub spawn { return if fork(); # Fork and return the parent exit shift->(); # exec the coderef passed as arg } sub foo { print '*' for(1..5); }
**************************************---Slept for 2 seconds **************************************---Slept for 2 seconds **************************************---Slept for 2 seconds **************************************---Slept for 2 seconds **************************************---Slept for 2 seconds
**************************************---Slept for 2 seconds **************************************---Did not sleep at all **************************************---Did not sleep at all *********************************---Did not sleep at all *******************************************---Slept for 2 seconds **********************************---Did not sleep at all *******************************************---Did not sleep at all
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why is SIGCHLD affecting sleep?
by ikegami (Patriarch) on Aug 09, 2007 at 22:38 UTC | |
by jsoverson (Novice) on Aug 09, 2007 at 22:41 UTC | |
|
Re: Why is SIGCHLD affecting sleep?
by jsoverson (Novice) on Aug 09, 2007 at 22:39 UTC | |
by Codon (Friar) on Aug 10, 2007 at 17:14 UTC | |
|
Re: Why is SIGCHLD affecting sleep?
by bruceb3 (Pilgrim) on Aug 10, 2007 at 22:06 UTC |