| 1 | #!/usr/bin/perl | ||
| 2 | # vim: ts=2 sw=2 expandtab | ||
| 3 | |||
| 4 | # Tests whether POE::Kernel affects signal handlers at initialization | ||
| 5 | # time. Based on test code provided by Stuart Kendrick, in | ||
| 6 | # rt.cpan.org ticket 19529. | ||
| 7 | |||
| 8 | use warnings; | ||
| 9 | use strict; | ||
| 10 | |||
| 11 | # perl-5.6.x on Win32 does not support alarm() | ||
| 12 | BEGIN { | ||
| 13 | if ( $^O eq 'MSWin32' and $] < 5.008 ) { | ||
| 14 | print "1..0 # Skip perl-5.6.x on $^O does not support alarm()"; | ||
| 15 | exit(); | ||
| 16 | } | ||
| 17 | } | ||
| 18 | |||
| 19 | use Test::More tests => 1; | ||
| 20 | |||
| 21 | BEGIN { | ||
| 22 | $SIG{ALRM} = \&dispatch_normal_signal; | ||
| 23 | } | ||
| 24 | |||
| 25 | my $signal_dispatched = 0; | ||
| 26 | |||
| 27 | sub dispatch_normal_signal { $signal_dispatched = 1 } | ||
| 28 | |||
| 29 | use POE; | ||
| 30 | |||
| 31 | alarm(1); | ||
| 32 | |||
| 33 | if ($^O eq "MSWin32") { | ||
| 34 | # Cant' select. Windows will get me! | ||
| 35 | # Windows has trouble with select() and undefined input vectors. | ||
| 36 | sleep(5); | ||
| 37 | } | ||
| 38 | else { | ||
| 39 | # Can't sleep. HP-UX will get me! | ||
| 40 | # HP-UX implements sleep() with alarm(), so they don't mix. | ||
| 41 | select(undef, undef, undef, 5); | ||
| 42 | } | ||
| 43 | |||
| 44 | ok($signal_dispatched, "normal SIGALRM dispatched"); | ||
| 45 | |||
| 46 | 1; |