Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Signals interrupt accept() - bug in perldoc perlipc?

Thread Tools

Signals interrupt accept() - bug in perldoc perlipc?

Peter Valdemar Morch
Posts: n/a
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:
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ruby bug with fork and signals (SIGTERM) Andreas Otto Ruby 2 10-12-2010 11:12 AM
ri and perldoc? Derek Smith Ruby 7 07-09-2010 03:56 PM
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
Tried Ruby (or, "what Python *really* needs" or "perldoc!") Python 27 03-17-2006 10:02 PM
Perldoc Equivalent? James Edward Gray II Ruby 19 09-06-2004 05:04 PM