X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2568ec7bdc945fa4beebf200756910f8b5b7903a..cc474141d4abcfe9c9b4b4dd02e692c5a8ed840a:/tools/tesh/tesh.pl diff --git a/tools/tesh/tesh.pl b/tools/tesh/tesh.pl index 2dd685b593..9db28ba2f8 100755 --- a/tools/tesh/tesh.pl +++ b/tools/tesh/tesh.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl +#! /usr/bin/env perl # Copyright (c) 2012-2014. The SimGrid Team. # All rights reserved. @@ -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; } }