2 # Copyright (c) 2014 IndexData ApS. http://indexdata.com
4 # bomb.pl - wrapper to stop a process after N seconds
16 binmode \*STDOUT, ":utf8";
17 binmode \*STDERR, ":utf8";
22 my $message = shift || "";
24 $time = 100 if !defined $time;
28 warn "Time out alarm $time\n";
30 # sends a hang-up signal to all processes in the current process group
31 # and kill running java processes
32 local $SIG{HUP} = "IGNORE";
35 local $SIG{TERM} = "IGNORE";
39 warn "Send a hang-up to all childs.\n";
44 warn "set alarm time to: $time seconds $message\n" if $debug >= 1;
50 usage: $0 [ options ] command args ....
52 --debug=0..3 debug option, default: $debug
53 --timeout=1..N timeout in seconds, default: $timeout
60 "timeout=i" => \$timeout,
66 die usage if !@system;
68 set_alarm( $timeout, join( " ", @system ) );
71 or die "system @system failed: $?";