2 # Copyright (C) 2001-2005, The Perl 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 - but
26 # signals are currently not enabled for all in src/events.c
27 # a second problem is to get the test doing the right thing: mainly figuring
28 # out what PID to kill. The "ps" command isn't one of the portable ones.
30 my %platforms = map { $_ => 1 } qw/
37 if ( $platforms{$^O} ) {
40 plan skip_all => 'Signals currently disabled';
43 plan skip_all => 'No events yet';
47 # A SIGHUP is sent to parrot from the alarm handler
48 # This is a non-portable hack.
53 grep { !/harness/ && !/sh -c/ } `ps axw | grep '[p]arrot'`;
61 die 'no output from ps' unless @ps;
63 # the IO thread parrot process
64 # on linux 2.2.x there are 4 processes, last is the IO thread
65 # posix compliant threads have exactly one PID for parrot
66 my $io_thread = pop @ps;
67 if ( $io_thread =~ /^\s*(\d+)/ ) {
74 die 'no pid found for parrot';
81 select undef, undef, undef, 0.1;
84 if ( $thread =~ /^\s*(\d+)/ && $1 == $pid ) {
85 ok( 0, "parrot $pid still running" );
88 ok( 1, 'parrot stopped' );
94 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - sleep" );
96 # no exception handler - parrot should die silently
108 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - loop" );
111 # no exception handler - parrot should die silently
115 # if 4G loops take less then 1 second, this will fail :)
125 skip( "works standalone but not in test", 1 );
128 pasm_output_is( <<'CODE', <<'OUTPUT', "SIGHUP event - sleep, catch" );
135 .include "signal.pasm"
143 print "something _type = "
159 # cperl-indent-level: 4
162 # vim: expandtab shiftwidth=4: