powerman has asked for the wisdom of the Perl Monks concerning the following question:
And how to create signal handler which will continue processing signals without interrupting system calls with EINTR?
use POSIX; $SIG = 10; $SIGNAME = "USR1"; #$SIG = 50; $SIGNAME = "NUM50"; $SIG{$SIGNAME} = sub { $got++ }; sigaction($SIG, undef, my $act=bless({}, "POSIX::SigAction")); $act->{FLAGS} |= &POSIX::SA_RESTART; sigaction($SIG, $act); my $parent_pid = $$; die "can't fork\n" unless defined(my $chield_pid = fork()); unless ($chield_pid) { select(undef,undef,undef, 0.1), kill($SIG, $parent_pid) while 1; } my $n = sysread \*STDIN, my $buf, 1; printf "got=%d n=%s err=%s\n", $got, defined($n) ? $n : "undef", $!; kill 9, $chield_pid;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Signals, SA_RESTART, and EINTR
by matija (Priest) on Apr 19, 2004 at 06:43 UTC |