You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] Embedded HTTP server writes can raise SIGPIPE and terminate the process #4293
There is no MSG_NOSIGNAL and no SO_NOSIGPIPE anywhere under ext/.
POSIX specifies that a write to a connected socket that can no longer transmit raises SIGPIPE as well as failing with EPIPE, unless the write suppresses it. The default disposition of SIGPIPE terminates the process, so an embedded server whose peer has gone away can take the host process down before any of the error handling in sendMore() runs.
Reproduced on Linux with a socketpair() whose peer end is closed, forking once per flag value:
flags = 0 -> KILLED by signal 13 (Broken pipe)
flags = MSG_NOSIGNAL -> exited 0
Suggested fix
Handle it inside Socket::send() rather than changing the host process signal disposition, since a library should not be deciding that for the program that embeds it.
Linux and other platforms that define MSG_NOSIGNAL: pass it per call.
macOS and BSD, which offer SO_NOSIGPIPE instead: set the socket option once, at socket creation and again on the socket returned by accept().
Windows: nothing to do, there is no SIGPIPE.
Worth doing before the fatal send error item in #4287, because otherwise the process can die before that error handling is ever reached.
Closing after @dbarker set the scope for these files on #4287, same reasoning as #4281 and #4282: socket_tools.h is internal and the bar for it is the tests and the example. #4294 is closed for the same reason. Recording one fact without arguing for it, since it bears on where that bar sits: an unhandled SIGPIPE ends the process rather than failing the call. I have not seen it happen in CI.
Activity
[BUG] Stop embedded HTTP server writes from raising SIGPIPE
thc1006 commentedon Aug 3, 2026
Closing after @dbarker set the scope for these files on #4287, same reasoning as #4281 and #4282:
socket_tools.his internal and the bar for it is the tests and the example. #4294 is closed for the same reason. Recording one fact without arguing for it, since it bears on where that bar sits: an unhandled SIGPIPE ends the process rather than failing the call. I have not seen it happen in CI.