S
Simon Andrews
I'm running a small daemon written in Perl which starts of a load of
jobs and keeps track of when they've finished. It's been running for
ages and works well, but following an OS upgrade its now spitting out
kernel warnings.
The script watches an Input directory for new files, if it finds them it
adds them to a queue and moves them to an output directory. It then
starts a separate processing routine. It keeps track of how many jobs
it is running and holds a queue for the rest.
Because I don't know what order the jobs will finish in I set
SIG{'CHLD'} = 'IGNORE' in the script to avoid picking up zombies and
dispense with wait. However I am now getting kernel warnings saying:
Jan 15 15:19:20 bilin3 kernel: application bug: cgi_blast_demon(2418)
has SIGCHLD set to SIG_IGN but calls wait().
I've cut the script down as much as I can whilst still preserving it's
basic structure. Can anyone see what would be calling wait here to
cause this error? Could I be getting this if the exec'd script calls
wait instead (it does, as it uses a system command)?
Any help is appreciated.
Simon.
#!/usr/bin/perl -w
use strict;
$SIG{CHLD} = 'IGNORE';
my %pids;
my @queue;
########################################
####### MAIN LOOP ######################
########################################
# We're a daemon so we should loop forever!
while (1) {
my @inputlist = `ls -1tr /data/temp/www/blast/Input`;
chomp @inputlist;
foreach my $id (@inputlist){
push (@queue,$id);
}
# Now check our existing processes are running
foreach my $pid (keys(%pids)){
delete $pids{$pid} unless (kill (0,$pid));
}
while (scalar @queue){
# We should start a new job off and add it's pid
# to the %pids hash
my $new_job = shift @queue;
rename("/data/Input/$new_job","/data/Output/$new_job") || die
"Can't move $new_job to Outout dir: $!";
my $new_pid = fork;
if ($new_pid){
# We're the parent, so we add the pid to the
# list of running PIDs
$pids{$new_pid}=$new_job;
}
else {
# We're the child
# Move to the correct directory
chdir("/data/Output/$new_job") || die "Can't move to
/data/BlastCGI/Output/$new_job : $!";
exec ("/usr/local/bin/actually_do_job.pl $new_job");
}
} # End lauch new jobs
sleep 3;
}
jobs and keeps track of when they've finished. It's been running for
ages and works well, but following an OS upgrade its now spitting out
kernel warnings.
The script watches an Input directory for new files, if it finds them it
adds them to a queue and moves them to an output directory. It then
starts a separate processing routine. It keeps track of how many jobs
it is running and holds a queue for the rest.
Because I don't know what order the jobs will finish in I set
SIG{'CHLD'} = 'IGNORE' in the script to avoid picking up zombies and
dispense with wait. However I am now getting kernel warnings saying:
Jan 15 15:19:20 bilin3 kernel: application bug: cgi_blast_demon(2418)
has SIGCHLD set to SIG_IGN but calls wait().
I've cut the script down as much as I can whilst still preserving it's
basic structure. Can anyone see what would be calling wait here to
cause this error? Could I be getting this if the exec'd script calls
wait instead (it does, as it uses a system command)?
Any help is appreciated.
Simon.
#!/usr/bin/perl -w
use strict;
$SIG{CHLD} = 'IGNORE';
my %pids;
my @queue;
########################################
####### MAIN LOOP ######################
########################################
# We're a daemon so we should loop forever!
while (1) {
my @inputlist = `ls -1tr /data/temp/www/blast/Input`;
chomp @inputlist;
foreach my $id (@inputlist){
push (@queue,$id);
}
# Now check our existing processes are running
foreach my $pid (keys(%pids)){
delete $pids{$pid} unless (kill (0,$pid));
}
while (scalar @queue){
# We should start a new job off and add it's pid
# to the %pids hash
my $new_job = shift @queue;
rename("/data/Input/$new_job","/data/Output/$new_job") || die
"Can't move $new_job to Outout dir: $!";
my $new_pid = fork;
if ($new_pid){
# We're the parent, so we add the pid to the
# list of running PIDs
$pids{$new_pid}=$new_job;
}
else {
# We're the child
# Move to the correct directory
chdir("/data/Output/$new_job") || die "Can't move to
/data/BlastCGI/Output/$new_job : $!";
exec ("/usr/local/bin/actually_do_job.pl $new_job");
}
} # End lauch new jobs
sleep 3;
}