+if ($ARGV[0] eq "--internal-killer-process") {
+ # We fork+exec a waiter process in charge of killing the command after timeout
+ # If the command stops earlier, that's fine: the killer sends a signal to an already stopped process, fails, and quits.
+ # Nobody cares about the killer issues.
+ # The only problem could arise if another process is given the same PID than cmd. We bet it won't happen :)
+ my $time_to_wait = $ARGV[1];
+ my $pid = $ARGV[2];
+ sleep $time_to_wait;
+ kill('TERM', $pid);
+ sleep 1;
+ kill('KILL', $pid);
+ exit $time_to_wait;
+}
+
+