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

Ingo Oeser ioe-news at rameria.de
Tue Sep 11 15:00:57 PDT 2007


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.

The default setting for SIGPIPE is to terminate the program, 
which is correct for simple programs not handling signals at all.

The preferred solution in Linux is to provide the flag MSG_NOSIGNAL 
in the flags parameter of send(2), sendto(2) and sendmsg(2).

But this symbol must be generated by gen_unix.c first, if defined.
(in function c_socket())


Best Regards

Ingo Oeser


More information about the Digitalmars-d-bugs mailing list