sub StartEditor() { eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm 60; #start the Editor exe my $commandline='"Editor.exe" /CAS-FILE=$file'; if ( (my $retcode = system($commandline)) != 0) { print (STDERR "'$commandline' returned non-ok confirmation code '$retcode'\n"); } alarm 0; }; if ($@) { # timed out print "StartEditor(): TIME OUT!\n"; #kill Editor.exe system ('taskkill /F /IM "Editor.exe"'); die #unless $@ eq "alarm\n"; } else { # didn't timeout print "StartEditor(): Finished Editor.exe\n"; } }