From 6e888e413ec6754c540988844dd5fdfde39f61c0 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Mon, 7 Apr 2014 15:48:24 +0000 Subject: [PATCH] move ./bomb.pl script to ./bin sub-directory --- test/bin/bomb.pl | 6 ++--- test/bomb.pl | 73 ------------------------------------------------------ 2 files changed, 3 insertions(+), 76 deletions(-) delete mode 100755 test/bomb.pl diff --git a/test/bin/bomb.pl b/test/bin/bomb.pl index a84f40b..f4b4cec 100755 --- a/test/bin/bomb.pl +++ b/test/bin/bomb.pl @@ -1,4 +1,4 @@ -#!/usr/local/bin/perl +#!/usr/bin/perl # Copyright (c) 2014 IndexData ApS. http://indexdata.com # # bomb.pl - wrapper to stop a process after N seconds @@ -57,7 +57,7 @@ EOF GetOptions( "help" => \$help, "debug=i" => \$debug, - "timeout=i" => \$timeout, + "timeout=f" => \$timeout, ) or die usage; my @system = @ARGV; @@ -68,6 +68,6 @@ die usage if !@system; set_alarm( $timeout, join( " ", @system ) ); system(@system) == 0 - or die "system @system failed: $?"; + or die "@system failed with exit code: $?\n"; exit(0); diff --git a/test/bomb.pl b/test/bomb.pl deleted file mode 100755 index f4b4cec..0000000 --- a/test/bomb.pl +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl -# Copyright (c) 2014 IndexData ApS. http://indexdata.com -# -# bomb.pl - wrapper to stop a process after N seconds -# - -use Getopt::Long; - -use strict; -use warnings; - -my $debug = 0; -my $help; -my $timeout = 100; - -binmode \*STDOUT, ":utf8"; -binmode \*STDERR, ":utf8"; - -# timeout handler -sub set_alarm { - my $time = shift; - my $message = shift || ""; - - $time = 100 if !defined $time; - - $SIG{ALRM} = sub { - - warn "Time out alarm $time\n"; - - # sends a hang-up signal to all processes in the current process group - # and kill running java processes - local $SIG{HUP} = "IGNORE"; - kill 1, -$$; - - local $SIG{TERM} = "IGNORE"; - kill 15, -$$; - kill 15, -$$; - - warn "Send a hang-up to all childs.\n"; - - #exit 1; - }; - - warn "set alarm time to: $time seconds $message\n" if $debug >= 1; - alarm($time); -} - -sub usage () { - < \$help, - "debug=i" => \$debug, - "timeout=f" => \$timeout, -) or die usage; - -my @system = @ARGV; - -die usage if $help; -die usage if !@system; - -set_alarm( $timeout, join( " ", @system ) ); - -system(@system) == 0 - or die "@system failed with exit code: $?\n"; - -exit(0); -- 1.7.10.4