X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F02-sigusr.t;fp=t%2F02-sigusr.t;h=abe83760b0bab75ec411ebb69db8dc2935155e2f;hb=eccac2c27337a828907205353fc7907da4c3e4a4;hp=8a048e9598b90c5302d7fa006c6da248039157c7;hpb=133946d2bfe0a5d47755a8f182a76e2f57b72e20;p=perl%2Fmodules%2FIPC-MorseSignals.git diff --git a/t/02-sigusr.t b/t/02-sigusr.t index 8a048e9..abe8376 100644 --- a/t/02-sigusr.t +++ b/t/02-sigusr.t @@ -2,7 +2,7 @@ use Test::More tests => 2; -use POSIX qw/SIGTERM SIGKILL EXIT_FAILURE EXIT_SUCCESS/; +use POSIX qw/SIGINT SIGTERM SIGKILL EXIT_SUCCESS EXIT_FAILURE WIFEXITED WEXITSTATUS/; sub trysig { my ($n, $s) = @_; @@ -12,14 +12,16 @@ sub trysig { } elsif ($pid == 0) { local $SIG{$s} = sub { exit EXIT_SUCCESS }; 1 while 1; + exit EXIT_FAILURE; } - my $ret = EXIT_FAILURE; + sleep 1; + my $ret = 0; eval { local $SIG{ALRM} = sub { die }; alarm 1; kill $n, $pid; waitpid $pid, 0; - $ret = $?; + $ret = (WIFEXITED($?) && (WEXITSTATUS($?) == EXIT_SUCCESS)); alarm 0; }; if ($@) { @@ -28,9 +30,8 @@ sub trysig { kill SIGKILL, $pid; die "$s: $@"; } - ok($ret == EXIT_SUCCESS, $s); + ok($ret, $s); } -sleep 1; trysig SIGUSR1, 'USR1'; trysig SIGUSR2, 'USR2';