sub childDone { # Resource is freed up so place it back in the queue to be used for future toasts. # $SIG{CHLD} = \&childDone; my $chld; $chld = waitpid(-1, WNOHANG) until $chld; return unless $chld > 0; #print "\n$$ sees $chld is done"; system(`touch /tmp/child.$chld`); # Toasting using this resource is now done my $str="toasting." . $jobs{$chld}; $cache->set($str,0); #print "\tresource " . $jobs{$chld} . " is free again!\n"; push @resource, $jobs{$chld}; #print "The resources to use are: @resource\n"; delete $jobs{$chld}; alarm 0; # send SIGALRM so sleep() wakes up }; $SIG{CHLD} = \&childDone;