From 95012189c0fb4776f1c50ef66a3b360b42f6c03b Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Fri, 16 Oct 2020 17:54:23 -0400 Subject: [PATCH] Cygwin: AF_UNIX: sendmsg: fix errno if socket is shut down Following Posix and Linux, the errno should be EPIPE, not ESHUTDOWN. --- winsup/cygwin/fhandler_socket_unix.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc index ed96bbe27..11a3623e3 100644 --- a/winsup/cygwin/fhandler_socket_unix.cc +++ b/winsup/cygwin/fhandler_socket_unix.cc @@ -2493,7 +2493,11 @@ fhandler_socket_unix::sendmsg (const struct msghdr *msg, int flags) } if (saw_shutdown () & _SHUT_SEND) { - set_errno (ESHUTDOWN); + set_errno (EPIPE); + /* FIXME: Linux calls for SIGPIPE here, but Posix + doesn't. Should we follow Linux? */ + if (!(flags & MSG_NOSIGNAL)) + raise (SIGPIPE); __leave; } }