X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a016b25437d8095a80a8d31965c5a33631839f24..cc474141d4abcfe9c9b4b4dd02e692c5a8ed840a:/tools/tesh/tesh.pl diff --git a/tools/tesh/tesh.pl b/tools/tesh/tesh.pl index e83cbc6441..9db28ba2f8 100755 --- a/tools/tesh/tesh.pl +++ b/tools/tesh/tesh.pl @@ -47,13 +47,16 @@ use Text::ParseWords; use IPC::Open3; use IO::File; -if($^O eq "linux"){ +# Existing OSes: https://metacpan.org/source/SMUELLER/PathTools-3.47/lib/File/Spec.pm +if($^O eq "linux" || $^O eq "MacOS"){ $OS = "UNIX"; -} -else{ +} elsif ($^O eq "MSWin32") { $OS = "WIN"; $ENV{"PRINTF_EXPONENT_DIGITS"} = "2"; +} else { + die "Tesh: Unknown operating system: $^O\n"; } +use if $^O eq 'MSWin32', 'Win32::Job'; ## ## Command line option handling @@ -280,9 +283,16 @@ sub exec_cmd { die "fork() failed: $!" unless defined $forked; if ( $forked == 0 ) { # child sleep $time_to_wait; - kill(SIGTERM, $cmd{'pid'}); - sleep 1; - kill(SIGKILL, $cmd{'pid'}); + if ($OS eq "UNIX") { + kill(SIGTERM, $cmd{'pid'}); + sleep 1; + kill(SIGKILL, $cmd{'pid'}); + } elsif ($OS eq "WIN") { + system("TASKKILL /F /T /PID $cmd{'pid'}"); + # /F: Forcefully + # /T: Tree kill + # /PID: poor soul + } exit $time_to_wait; } }