From a353544f60e704aca2e4bb68ae8a59e16e7a8624 Mon Sep 17 00:00:00 2001 From: Wolfram Schneider Date: Tue, 8 Apr 2014 15:40:45 +0000 Subject: [PATCH] use fork/exec() instead system, MKWS-157 simplify alarm() handling --- test/bin/bomb.pl | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/test/bin/bomb.pl b/test/bin/bomb.pl index 5671a53..6211eab 100755 --- a/test/bin/bomb.pl +++ b/test/bin/bomb.pl @@ -5,6 +5,7 @@ # use Getopt::Long; +use POSIX ":sys_wait_h"; use strict; use warnings; @@ -12,38 +13,11 @@ use warnings; my $debug = 0; my $help; my $timeout = 100; +my $pid; 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 - local $SIG{HUP} = "IGNORE"; - kill 1, -$$; - sleep 0.2; - - local $SIG{TERM} = "IGNORE"; - kill 15, -$$; - sleep 0.2; - kill 15, -$$; - - warn "Send a hang-up to all childs.\n"; - }; - - warn "set alarm time to: $time seconds $message\n" if $debug >= 1; - alarm($time); -} - sub usage () { <