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;
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;
}
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{