From: Marius Gavrilescu Date: Wed, 29 Jul 2015 11:29:42 +0000 (+0300) Subject: Start gruntmaster-exec alarm just before exec X-Git-Tag: 5999.000_005~10 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=0418cda23eb73ee9be138d4f8fab977927132007;p=gruntmaster-daemon.git Start gruntmaster-exec alarm just before exec This way, a part of the time needed for setup (forking, opening files, setting limits) no longer counts against the time limit. --- diff --git a/gruntmaster-exec b/gruntmaster-exec index b6577f4..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; @@ -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; } diff --git a/lib/Gruntmaster/Daemon/Format.pm b/lib/Gruntmaster/Daemon/Format.pm index cd0e47d..0a73611 100644 --- a/lib/Gruntmaster/Daemon/Format.pm +++ b/lib/Gruntmaster/Daemon/Format.pm @@ -63,7 +63,7 @@ sub execlist { unlink $er; chomp ($excode, $exmsg); ## no critic (ProhibitParensWithBuiltins) get_logger->trace("Exec result: $excode $exmsg"); - die [$excode, $exmsg] if $excode > 0; ## no critic (RequireCarping) + die [$excode, $exmsg] if $excode; ## no critic (RequireCarping) } sub mkrun{