2 # Copyright (C) 2001-2008, Parrot Foundation.
7 use lib qw( . lib ../lib ../../lib );
13 t/pmc/signal.t - Signal Handling
17 % prove t/pmc/signal.t
21 Tests signal handling.
25 # actually more platforms should work - all POSIX compliant ones
26 # a second problem is to get the test doing the right thing: mainly figuring
27 # out what PID to kill. The "ps" command isn't one of the portable ones.
29 my %platforms = map { $_ => 1 } qw/
36 if ( $platforms{$^O} ) {
39 plan skip_all => 'Signals currently disabled';
42 plan skip_all => 'No events yet';
46 # A SIGHUP is sent to parrot from the alarm handler
47 # This is a non-portable hack.
52 grep { !/harness/ && !/sh -c/ } `ps axw | grep '[p]arrot'`;
60 die 'no output from ps' unless @ps;
62 # the IO thread parrot process
63 # on linux 2.2.x there are 4 processes, last is the IO thread
64 # posix compliant threads have exactly one PID for parrot
65 my $io_thread = pop @ps;
66 if ( $io_thread =~ /^\s*(\d+)/ ) {
73 die 'no pid found for parrot';
80 select undef, undef, undef, 0.1;
83 if ( $thread =~ /^\s*(\d+)/ && $1 == $pid ) {
84 ok( 0, "parrot $pid still running" );
87 ok( 1, 'parrot stopped' );
93 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - sleep" );
95 # no exception handler - parrot should die silently
107 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - loop" );
110 # no exception handler - parrot should die silently
114 # if 4G loops take less then 1 second, this will fail :)
124 skip( "works standalone but not in test", 1 );
127 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - sleep, catch" );
134 .include "signal.pasm"
142 print "something _type = "
158 # cperl-indent-level: 4
161 # vim: expandtab shiftwidth=4: