TT#111905 perl system() wrapper

Change-Id: I6dc8d73ff0c03ef22d2336b6f82077e257547a98
(cherry picked from commit f9222f2f97)
mr7.5.5
Rene Krenn 5 years ago
parent 943b1cea92
commit a1495628bd

@ -113,6 +113,7 @@ our @EXPORT_OK = qw(
check_ipnet
unshare
run
);
our $chmod_umask = 0777;
@ -1060,4 +1061,26 @@ sub unshare {
}
sub run {
my (@commandandargs) = @_;
system(@commandandargs);
my $command = shift @commandandargs;
if ($? == -1) {
return (0,'failed to execute ' . $command . ': ' . $!);
} elsif ($? & 127) {
return (0,sprintf($command . ' died with signal %d, %s dump', ($? & 127), ($? & 128) ? 'with' : 'without'));
} else {
if ($? == 0) {
return (1,sprintf($command . ' exited with value %d', $? >> 8));
} else {
return (0,sprintf($command . ' exited with value %d', $? >> 8));
}
}
}
1;

Loading…
Cancel
Save