Does "write" or "send" to a closed socket generate a SIGPIPE

Does “write” or “send” to a closed socket ever generate SIGPIPE signals?
The documentation says it does for a pipe or FIFO, but what about
sockets? Thanks.

John Nagle

Yes. If you don’t like this you can set signal(SIGPIPE, SIG_IGN)
and the write() / send() / sendto() / sendmsg() will fail with
-1 with errno of EPIPE.

Regards,

-seanb


John Nagle <nagle@overbot.com> wrote:

Does “write” or “send” to a closed socket ever generate SIGPIPE signals?
The documentation says it does for a pipe or FIFO, but what about
sockets? Thanks.

John Nagle

John Nagle <nagle@overbot.com> wrote:

Does “write” or “send” to a closed socket ever generate SIGPIPE signals?
The documentation says it does for a pipe or FIFO, but what about
sockets? Thanks.

Yes. TCP sockets inherit much of the behaviour of a pipe.

I don’t think you’ll get this with a UDP socket, though.

-David

David Gibbs
QNX Training Services
dagibbs@qnx.com