#!/usr/bin/perl use strict; use warnings; my $commandline='"Editor.exe" /CAS-FILE=$file'; my $timeout=160; #Sekunden local $SIG{CHLD}='IGNORE'; my $pid=fork; die("Fork failed!") unless(defined($pid)); if($pid) { my $start=time(); while($start+$timeout > time()) { sleep 1; last unless(kill(0,$pid)); } # Zeit abgelaufen und Prozess läuft noch if($start+$timeout <= time() && kill(0,$pid)) { # Prozess beenden # erster Versuch # freundlich fragen kill(15,$pid); sleep 2; # zweiter versuch if(kill(0,$pid)) { kill(15,$pid); sleep 2; # das dritte mal Prozess abwürgen! kill(9,$pid) if(kill(0,$pid)); } } } else { # externes Programm mit der aktuellen Prozess ID starten exec($commandline); }