# HG changeset patch # User Christian Arnold # Date 1293004351 -3600 # Node ID ded3b78c61b17f93ec1dfc172af32fa6686ac5cb # Parent 9b0a5c2b7ebc9cb4fa5909c260a77d36ddb3352c * now execute program with exec() diff -r 9b0a5c2b7ebc -r ded3b78c61b1 check_exec.pl --- a/check_exec.pl Tue Dec 21 15:19:21 2010 +0100 +++ b/check_exec.pl Wed Dec 22 08:52:31 2010 +0100 @@ -66,54 +66,7 @@ my @cmd = ($run_file); - open(OUTPUT, "-|") or do { - open(STDERR, ">&STDOUT"); - system(@cmd); - }; - - my $result = ; - - close(OUTPUT); - - if ($? == -1) { - print "EXEC CRITICAL: Failed to execute: $!\n"; - cleanup($run_file); - exit $ERRORS{CRITICAL}; - } - elsif ($? & 127) { - printf "EXEC CRITICAL: Child died with signal %d, %s coredump\n", - ($? & 127), ($? & 128) ? 'with' : 'without'; - cleanup($run_file); - exit $ERRORS{CRITICAL}; - } - else { - my $rc = $? >> 8; - if ($rc == $ERRORS{OK}) { - print "EXEC OK: $result"; - cleanup($run_file); - exit $ERRORS{OK}; - } - elsif ($rc == $ERRORS{WARNING}) { - print "EXEC WARNING: $result"; - cleanup($run_file); - exit $ERRORS{WARNING}; - } - elsif ($rc == $ERRORS{CRITICAL}) { - print "EXEC CRITICAL: $result"; - cleanup($run_file); - exit $ERRORS{CRITICAL}; - } - elsif ($rc == $ERRORS{UNKNOWN}) { - print "EXEC UNKNOWN: $result"; - cleanup($run_file); - exit $ERRORS{UNKNOWN}; - } - elsif ($rc == $ERRORS{DEPENDENT}) { - print "EXEC DEPENDENT: $result"; - cleanup($run_file); - exit $ERRORS{DEPENDENT}; - } - } + exec(@cmd) or print "EXEC CRITICAL: Couldn't exec $run_file ($!)"; } sub cleanup($) {