From: David van Moolenbroek Date: Mon, 9 May 2016 09:55:07 +0000 (+0000) Subject: Do not hide the MSG_NOSIGNAL flag X-Git-Url: http://zhaoyanbai.com/repos/man.rndc.conf.html?a=commitdiff_plain;h=refs%2Fchanges%2F24%2F3324%2F1;p=minix.git Do not hide the MSG_NOSIGNAL flag Instead, filter it in libc for old networking implementations, as those do not support sending SIGPIPE to user processes anyway. This change allows newer socket drivers to implement the flag as per the specification. Change-Id: I423bdf28ca60f024a344d0a73e2eab38f1b269da --- diff --git a/minix/lib/libc/sys/sendmsg.c b/minix/lib/libc/sys/sendmsg.c index 4d4452cff..846d67dc6 100644 --- a/minix/lib/libc/sys/sendmsg.c +++ b/minix/lib/libc/sys/sendmsg.c @@ -96,6 +96,9 @@ ssize_t sendmsg(int sock, const struct msghdr *msg, int flags) return -1; } + /* For old socket driver implementations, this flag is the default. */ + flags &= ~MSG_NOSIGNAL; + r= ioctl(sock, NWIOGUDSSOTYPE, &uds_sotype); if (r != -1 || errno != ENOTTY) { if (r == -1) { diff --git a/minix/lib/libc/sys/sendto.c b/minix/lib/libc/sys/sendto.c index 77304f301..c194c8182 100644 --- a/minix/lib/libc/sys/sendto.c +++ b/minix/lib/libc/sys/sendto.c @@ -66,6 +66,9 @@ ssize_t sendto(int sock, const void *message, size_t length, int flags, if (r != -1 || (errno != ENOTSOCK && errno != ENOSYS)) return r; + /* For old socket driver implementations, this flag is the default. */ + flags &= ~MSG_NOSIGNAL; + r= ioctl(sock, NWIOGTCPOPT, &tcpopt); if (r != -1 || errno != ENOTTY) { diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 6b3a1190c..219b90baf 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -521,9 +521,7 @@ struct msghdr { #define MSG_DONTWAIT 0x0080 /* this message should be nonblocking */ #define MSG_BCAST 0x0100 /* this message was rcvd using link-level brdcst */ #define MSG_MCAST 0x0200 /* this message was rcvd using link-level mcast */ -#if !defined(__minix) #define MSG_NOSIGNAL 0x0400 /* do not generate SIGPIPE on EOF */ -#endif /* !defined(__minix) */ #if defined(_NETBSD_SOURCE) #define MSG_CMSG_CLOEXEC 0x0800 /* close on exec receiving fd */ #define MSG_NBIO 0x1000 /* use non-blocking I/O */