X-Git-Url: http://git.ieval.ro/?p=gruntmaster-daemon.git;a=blobdiff_plain;f=gruntmaster-exec;h=fd79d8f316c322c9008f14bbe98b402772011c77;hp=5235e8e5ed3430fa06b37a73a8bc5304c78d54ae;hb=0418cda23eb73ee9be138d4f8fab977927132007;hpb=2ddfc5472cd27c537a9c37e3e6074c3f3997dc0d diff --git a/gruntmaster-exec b/gruntmaster-exec index 5235e8e..fd79d8f 100755 --- a/gruntmaster-exec +++ b/gruntmaster-exec @@ -46,7 +46,13 @@ undef $mlimit if @sudo; # sudo wants a lot of address space my $ret = fork // die 'Cannot fork'; if ($ret) { - my $tle; + my ($tle, $child_ready); + local $SIG{USR1} = sub { $child_ready = 1 }; + sleep 3; # Wait for ready signal (SIGUSR1) + unless ($child_ready) { + kill KILL => $ret; + exit !say ERR, "\nNo response from gruntmaster-exec child"; + } local $SIG{ALRM} = sub { if ($killuser) { system @sudo, 'pkill', '-KILL', '-u', $killuser; @@ -66,7 +72,7 @@ if ($ret) { my $signame = sig_name $sig; exit !say TLE, "\nTime Limit Exceeded" if $tle; exit !say OLE, "\nOutput Limit Exceeded" if $sig && $signame eq 'XFSZ'; - exit !say DIED, "\nCrash (SIG$signame)" if $sig && $signame ne 'PIPE'; + exit !say DIED, "\nCrash (SIG$signame)" if $sig && ($signame ne 'PIPE' || $ARGV[0] !~ /prog/); exit !say NZX, "\nNon-zero exit status: " . ($? >> 8) if $? >> 8; exit !say AC, "\nAll OK"; } else { @@ -92,6 +98,7 @@ if ($ret) { print $adj 900; close $adj; unshift @ARGV, @sudo; + kill USR1 => getppid; # Tell parent process that we're ready say STDERR "Executing: ", join ' ', map { "'$_'" } @ARGV if $debug; exec @ARGV; }