Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Use <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/sigaction.2.html" rel="nofollow noreferrer"><code>sigaction()</code></a> to set the action for <code>SIGPIPE</code> to <code>SIG_IGN</code>. Then you will just get the return code of -1 with <code>errno</code> set to <code>EPIPE</code>, without the signal.</p> <p>On Linux, an alternative is to use <a href="http://www.kernel.org/doc/man-pages/online/pages/man2/send.2.html" rel="nofollow noreferrer"><code>send()</code></a> with the <code>MSG_NOSIGNAL</code> flag, instead of <code>write()</code>. This allows you to suppress the signal for that write, without affecting any others. An alternative on BSD systems is the <code>SO_NOSIGPIPE</code> socket option, which suppresses <code>SIGPIPE</code> for all writes on that socket.</p> <p>At any time the kernel TCP implementation may receive a TCP RST from the peer. The next write on the socket after that point will result in the <code>EPIPE</code> error, and the <code>SIGPIPE</code> signal if it was not suppressed. So even with two consecutive writes, the first could be successful and the next one could fail with EPIPE and SIGPIPE.</p> <p><strong>Update:</strong> Although it is not part of the code that was posted, I see in your strace output that you are calling <code>fcntl64(5, F_SETFL, O_RDONLY|O_NONBLOCK)</code>. Since <code>O_RDONLY</code> is 0, probably your code just sets the flags to <code>O_NONBLOCK</code>. It should get the current flags and then set it to <code>OldFlags | O_NONBLOCK</code> in order to set non-blocking mode. Setting a socket to read-only mode seems likely to cause a problem when writing. Or it may be that you accidentally used <code>F_GETFD</code> instead of <code>F_GETFL</code> to get the old flags.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload