This (waitpid returning) may be the case with OP's legacy environment.
Current perl appears to set up the signal handlers with SA_RESTART. In this case, the (wait4) syscall returns ERESTARTSYS and is automatically restarted by the libc wrapper.
#! /usr/bin/perl use strict; use warnings; $SIG{QUIT} = "IGNORE"; my $pid = fork() // die; unless ($pid) { exit !exec "sleep 100"; } $SIG{ALRM} = sub { warn "SIGALRM\n" }; $SIG{QUIT} = sub { warn "SIGQUIT\n" }; warn "childpid = $pid\n"; alarm(2); warn "interrupted\n" while waitpid(-1, 0) == -1 and $!{EINTR};
Your advice is sound, however. Periodic polling is a hackish workaround. Unix has interrupts (^C ^\), and where possible, one ought to go with those. The alternative it to handle SIGCHLD and just keep reading/selecting on STDIN.
In reply to Re^2: Allowing user to abort waitpid
by Anonymous Monk
in thread Allowing user to abort waitpid
by lab007
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |