From e2c70b77729d9057309bc70446be09ef30486ec9 Mon Sep 17 00:00:00 2001 From: Antonio Huete Jimenez Date: Wed, 6 Oct 2010 22:16:03 +0200 Subject: [PATCH] send(2) - Add MSG_NOSIGNAL flag. POSIX:2008 introduces the MSG_NOSIGNAL flag that requests not to send the SIGPIPE signal if an attempt to send is made on a stream-oriented socket that is no longer connected. The EPIPE error shall still be returned. This fixes the build of multimedia/gst-plugins-bad in current pkgsrc. --- lib/libc/sys/send.2 | 10 ++++++++-- sys/kern/uipc_syscalls.c | 3 +-- sys/sys/socket.h | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2 index 1fec3984fb..bba5f86d9a 100644 --- a/lib/libc/sys/send.2 +++ b/lib/libc/sys/send.2 @@ -31,9 +31,8 @@ .\" .\" From: @(#)send.2 8.2 (Berkeley) 2/21/94 .\" $FreeBSD: src/lib/libc/sys/send.2,v 1.10.2.6 2001/12/14 18:34:01 ru Exp $ -.\" $DragonFly: src/lib/libc/sys/send.2,v 1.9 2007/06/30 19:03:52 swildner Exp $ .\" -.Dd February 15, 1995 +.Dd October 6, 2010 .Dt SEND 2 .Os .Sh NAME @@ -111,6 +110,7 @@ parameter may include one or more of the following: #define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */ #define MSG_EOR 0x8 /* data completes record */ #define MSG_EOF 0x100 /* data completes transaction */ +#define MSG_NOSIGNAL 0x400 /* No SIGPIPE to unconnected socket stream */ .Ed .Pp The flag @@ -135,6 +135,12 @@ sockets in the protocol family. .Dv MSG_DONTROUTE is usually used only by diagnostic or routing programs. +.Dv MSG_NOSIGNAL +requests not to send the +.Dv SIGPIPE +signal if an attempt to +.Nm +is made on a stream-oriented socket that is no longer connected. .Pp See .Xr recv 2 diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index c30ea34e55..a038d48bde 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -35,7 +35,6 @@ * * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94 * $FreeBSD: src/sys/kern/uipc_syscalls.c,v 1.65.2.17 2003/04/04 17:11:16 tegge Exp $ - * $DragonFly: src/sys/kern/uipc_syscalls.c,v 1.92 2008/11/26 13:10:56 sephe Exp $ */ #include "opt_ktrace.h" @@ -696,7 +695,7 @@ kern_sendmsg(int s, struct sockaddr *sa, struct uio *auio, if (auio->uio_resid != len && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) error = 0; - if (error == EPIPE) + if (error == EPIPE && !(flags & MSG_NOSIGNAL)) lwpsignal(p, lp, SIGPIPE); } #ifdef KTRACE diff --git a/sys/sys/socket.h b/sys/sys/socket.h index a41c30d644..a346a63f78 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -32,7 +32,6 @@ * * @(#)socket.h 8.4 (Berkeley) 2/21/94 * $FreeBSD: src/sys/sys/socket.h,v 1.39.2.7 2001/07/03 11:02:01 ume Exp $ - * $DragonFly: src/sys/sys/socket.h,v 1.23 2008/11/10 18:16:51 dillon Exp $ */ #ifndef _SYS_SOCKET_H_ @@ -362,6 +361,7 @@ struct msghdr { #define MSG_DONTWAIT 0x00000080 /* this message should be nonblocking */ #define MSG_EOF 0x00000100 /* data completes connection */ #define MSG_NOTIFICATION 0x00000200 /* notification message */ +#define MSG_NOSIGNAL 0x00000400 /* No SIGPIPE to unconnected socket stream */ /* * These override FIONBIO. MSG_FNONBLOCKING is functionally equivalent to -- 2.41.0