11 if( !$Config{d_alarm} ) {
12 skip_all("alarm() not implemented on this platform");
17 my $Perl = which_perl();
19 my $start_time = time;
21 local $SIG{ALRM} = sub { die "ALARM!\n" };
24 # perlfunc recommends against using sleep in combination with alarm.
25 1 while (time - $start_time < 6);
28 my $diff = time - $start_time;
30 # alarm time might be one second less than you said.
31 is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs inf loop' );
32 ok( abs($diff - 3) <= 1, " right time" );
35 my $start_time = time;
37 local $SIG{ALRM} = sub { die "ALARM!\n" };
39 system(qq{$Perl -e "sleep 6"});
42 $diff = time - $start_time;
44 # alarm time might be one second less than you said.
45 is( $@, "ALARM!\n", 'alarm w/$SIG{ALRM} vs system()' );
48 local $TODO = "Why does system() block alarm() on $^O?"
49 if $^O eq 'VMS' || $^O eq'MacOS' || $^O eq 'dos';
50 ok( abs($diff - 3) <= 1, " right time (waited $diff secs for 3-sec alarm)" );