[Issue 1491] New: if working with timed-out socket, SIGPIPE will kill program

Downs default_357-line at yahoo.de
Tue Sep 11 21:26:06 PDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ingo Oeser wrote:
> d-bugmail at puremagic.com wrote:
> 
>> On linux, when trying to work with a socket that has already expired, the
>> signal SIGPIPE is raised.
>> If unchecked, it will terminate the program.
>> Since there is a defined behavior for trying to work with timed-out
>> sockets (send/receive return -1), we can safely ignore this signal.
>> The following patch for gdc's std/thread.d (should be equally applicable
>> to dmd) implements this:
> 
> No! NACK!
> 
> Signals are a global state.
> 
> Libraries should never modify them in that manner, since
> the defaults are well documented in signal(7) and programs
> might expect this behaviour.
I disagree on this. The only behavior std/socket.d should exhibit is the
behavior documented in http://digitalmars.com/d/phobos/std_socket.html.
Unix signals are a platform specific feature that somebody writing a
platform independent program should _not_ have to mess with.

> 
> The default setting for SIGPIPE is to terminate the program, 
> which is correct for simple programs not handling signals at all.
> 
But this behavior is neither documented in std_socket.html, nor is it
platform independent, nor is there a platform independent way to
_prevent it_.

> The preferred solution in Linux is to provide the flag MSG_NOSIGNAL 
> in the flags parameter of send(2), sendto(2) and sendmsg(2).
> 
Okay, well great! If there's a proper way to suppress this behavior, by
all means, let's do that instead! But please, don't force the user to
write platform dependent code. That's what standard libraries are for.

> But this symbol must be generated by gen_unix.c first, if defined.
> (in function c_socket())
> 
> 
Right, my patch isn't very clean. It was mainly along the lines of "hey,
this worked for me" :)
> Best Regards
> 
> Ingo Oeser
 --downs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG52pepEPJRr05fBERAkhJAJ9Bv4DsPUvQQwKJQ1yC8lbKSP4hrgCgg0AT
yPxQCb9/hgAt0vng8rKJ/zE=
=jS6v
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-bugs mailing list