[vlc-commits] rootwrap: work around missing MSG_NOSIGNAL on old BSD derivatives

Rémi Denis-Courmont git at videolan.org
Thu May 21 20:55:05 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 21 20:51:59 2015 +0300| [2193b044d608d0a09af59920af32aa6384913afb] | committer: Rémi Denis-Courmont

rootwrap: work around missing MSG_NOSIGNAL on old BSD derivatives

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2193b044d608d0a09af59920af32aa6384913afb
---

 bin/rootwrap.c         |    4 +++-
 src/network/rootbind.c |    6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/bin/rootwrap.c b/bin/rootwrap.c
index 55944ac..77d9fd2 100644
--- a/bin/rootwrap.c
+++ b/bin/rootwrap.c
@@ -44,10 +44,12 @@
 # warning Uho, your IPv6 support is broken and has been disabled. Fix your C library.
 # undef AF_INET6
 #endif
-
 #ifndef AF_LOCAL
 # define AF_LOCAL AF_UNIX
 #endif
+#if !defined(MSG_NOSIGNAL) && defined(SO_NOSIGPIPE)
+# define MSG_NOSIGNAL 0
+#endif
 /* Required yet non-standard cmsg functions */
 #ifndef CMSG_ALIGN
 # define CMSG_ALIGN(len) (((len) + sizeof(intptr_t)-1) & ~(sizeof(intptr_t)-1))
diff --git a/src/network/rootbind.c b/src/network/rootbind.c
index 9c24c97..3b1f953 100644
--- a/src/network/rootbind.c
+++ b/src/network/rootbind.c
@@ -57,6 +57,12 @@ int rootwrap_bind (int, int, int, const struct sockaddr *, size_t);
 #ifndef CMSG_LEN
 # define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
 #endif
+#if !defined(MSG_NOSIGNAL)
+/* If the other end of the pipe hangs up and MSG_NOSIGNAL is missing, the
+ * process will get a (likely fatal) SIGPIPE signal. Then again, the other end
+ * can screw us up in various ways already (e.g. not answer to deadlock). */
+# define MSG_NOSIGNAL 0
+#endif
 
 #if defined(__OS2__) && !defined(ALIGN)
 /* CMSG_NXTHDR requires this */



More information about the vlc-commits mailing list