From 93ba120429991bd12645ef9c87e44d7464be75bb Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 31 Mar 2004 10:10:59 +0000 Subject: * fhandler_socket.cc (fhandler_socket::sendmsg): Add SIGPIPE handling. --- winsup/cygwin/fhandler_socket.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'winsup/cygwin/fhandler_socket.cc') diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index ccc1bef77..a410e15ac 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -1100,6 +1100,19 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags, ssize_t tot) res = ret; } + /* Special handling for EPIPE and SIGPIPE. + + EPIPE is generated if the local end has been shut down on a connection + oriented socket. In this case the process will also receive a SIGPIPE + unless MSG_NOSIGNAL is set. */ + if (res == SOCKET_ERROR && get_errno () == ESHUTDOWN + && get_socket_type () == SOCK_STREAM) + { + set_errno (EPIPE); + if (! (flags & MSG_NOSIGNAL)) + raise (SIGPIPE); + } + return res; } -- cgit v1.2.3