Reputation: 3989
Anyone ever heard of a SIGPIPE with no obvious reason? I have a program, which crashed with a SIGPIPE. I prevented the crash with signal(SIGPIPE, SIG_IGN); Out of curiosity I did nothing else, i.e. no error handling. To my surprise the code works fine. I communicate with another program via one socket. And the data transfer through the socket works perfectly even after the SIGPIPE. Is this possible? SIGPIPE due to a temporary network hickup?
Upvotes: 0
Views: 759
Reputation: 229058
That's how sockets work on *nixes.
Basically what happened is that you did a write()/send() or similar on a TCP socket that was reset by the peer. This will by default result in a SIGPIPE signal that terminates the application.
The common way to cope with this is to simply ignore the SIGPIPE signal as you've already done, and instead handle the error return value from write()/send().
More info can be found here, see chapter 2.19 and 2.22
Upvotes: 3