* now execute program with exec()
authorChristian Arnold <arnold@schlittermann.de>
Wed, 22 Dec 2010 08:52:31 +0100
changeset 2 ded3b78c61b1
parent 1 9b0a5c2b7ebc
child 3 211e08d0d2b8
* now execute program with exec()
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 = <OUTPUT>;
-
-    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($) {