captureStdoutStderr*: move to Hydra::Helper::Exec which helps avoid some environment variable fixation problems

This commit is contained in:
Graham Christensen
2022-02-09 13:40:51 -05:00
parent 1abe7f4d80
commit 845e6d4760
16 changed files with 54 additions and 50 deletions

View File

@ -18,8 +18,6 @@ use UUID4::Tiny qw(is_uuid4_string);
our @ISA = qw(Exporter);
our @EXPORT = qw(
cancelBuilds
captureStdoutStderr
captureStdoutStderrWithStdin
constructRunCommandLogPath
findLog
gcRootFor
@ -429,30 +427,7 @@ sub pathIsInsidePrefix {
}
sub captureStdoutStderr {
my ($timeout, @cmd) = @_;
return captureStdoutStderrWithStdin($timeout, \@cmd, "");
}
sub captureStdoutStderrWithStdin {
my ($timeout, $cmd, $stdin) = @_;
my $stdout;
my $stderr;
eval {
local $SIG{ALRM} = sub { die "timeout\n" }; # NB: \n required
alarm $timeout;
IPC::Run::run($cmd, \$stdin, \$stdout, \$stderr);
alarm 0;
1;
} or do {
die unless $@ eq "timeout\n"; # propagate unexpected errors
return (-1, $stdout, ($stderr // "") . "timeout\n");
};
return ($?, $stdout, $stderr);
}
sub run {