Start gruntmaster-exec alarm just before exec
[gruntmaster-daemon.git] / gruntmaster-exec
index b6577f4649206fee2e1cd108b6ec62cce581d8f1..fd79d8f316c322c9008f14bbe98b402772011c77 100755 (executable)
@@ -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;
 }
This page took 0.009834 seconds and 4 git commands to generate.