P
Peter Valdemar Morch
I've discovered that at least CHLD signals in 5.8.0+ terminate
accept(Client,Server) calls, so accept() now returns undef if CHLD is
recieved if a %SIG signal handler has been assigned. Also, posts in
this group have suggested to test for $! == EINTR, but on my Debian
Testing 5.8.3, $! == ECHILD, not EINTR. (Is this significant?)
In 5.6.0 on Linux, the accept() call blocked until a server connected,
regardless of signals. I expect that this change is related to "Safe
Signals" in 5.8, but I didn't quite expect this behavior from the
vague "Note that breaking out from potentially blocking operations
should still work, though" in perldoc perl58delta. At least the
behavior of accept() has changed...
Have any other signal related behaviors changed in a similar fashion?
(So I can proactively inspect and fix bugs rather than find them
through testing ;-)
Unless I have misunderstood something, I suggest that the loop in the
Socket Server example in perldoc perlipc:
for ( ; $paddr = accept(Client,Server); close Client) {
... e.g. start and terminate sub-process ...
}
is changed to:
while (1) {
my $paddr = accept($clientHandle,Server);
# Here $! == ECHILD, and not == EINTR as suggested in accept(2)
# when a child finishes, so don't test $! in case you add
# other signal handling later
if ($paddr) {
... e.g. start and terminate sub-process ...
}
}
(I had to change a similar loop in my own code)
Because otherwise, if a subprocess ends during the accept() call,
causing \&REAPER to be called, accept will return false and end the
for loop, that really was intended to run indefinitely.
Perhaps a mention of this interrupted accept() behaviour is also
warranted in perldoc -f accept and in perldoc perl58delta.
Some working examples that demonstrate the behavior can be found here:
http://demo.capmon.dk/~pvm/clientServer-5.8/
accept(Client,Server) calls, so accept() now returns undef if CHLD is
recieved if a %SIG signal handler has been assigned. Also, posts in
this group have suggested to test for $! == EINTR, but on my Debian
Testing 5.8.3, $! == ECHILD, not EINTR. (Is this significant?)
In 5.6.0 on Linux, the accept() call blocked until a server connected,
regardless of signals. I expect that this change is related to "Safe
Signals" in 5.8, but I didn't quite expect this behavior from the
vague "Note that breaking out from potentially blocking operations
should still work, though" in perldoc perl58delta. At least the
behavior of accept() has changed...
Have any other signal related behaviors changed in a similar fashion?
(So I can proactively inspect and fix bugs rather than find them
through testing ;-)
Unless I have misunderstood something, I suggest that the loop in the
Socket Server example in perldoc perlipc:
for ( ; $paddr = accept(Client,Server); close Client) {
... e.g. start and terminate sub-process ...
}
is changed to:
while (1) {
my $paddr = accept($clientHandle,Server);
# Here $! == ECHILD, and not == EINTR as suggested in accept(2)
# when a child finishes, so don't test $! in case you add
# other signal handling later
if ($paddr) {
... e.g. start and terminate sub-process ...
}
}
(I had to change a similar loop in my own code)
Because otherwise, if a subprocess ends during the accept() call,
causing \&REAPER to be called, accept will return false and end the
for loop, that really was intended to run indefinitely.
Perhaps a mention of this interrupted accept() behaviour is also
warranted in perldoc -f accept and in perldoc perl58delta.
Some working examples that demonstrate the behavior can be found here:
http://demo.capmon.dk/~pvm/clientServer-5.8/