OSDN Git Service

network: prevent SIGPIPE on OSX
authorwm4 <nfxjfg@googlemail.com>
Thu, 28 May 2015 16:23:27 +0000 (18:23 +0200)
committerMartin Storsjö <martin@martin.st>
Sun, 31 May 2015 07:10:16 +0000 (10:10 +0300)
OSX does not know MSG_NOSIGNAL. BSD (which OSX is based on) has got
the socket option SO_NOSIGPIPE (even if modern BSDs also support
MSG_NOSIGNAL).

Signed-off-by: Martin Storsjö <martin@martin.st>
libavformat/network.c

index a12e70d..2c34b4a 100644 (file)
@@ -153,6 +153,10 @@ int ff_socket(int af, int type, int proto)
             fcntl(fd, F_SETFD, FD_CLOEXEC);
 #endif
     }
+#ifdef SO_NOSIGPIPE
+    if (fd != -1)
+        setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &(int){1}, sizeof(int));
+#endif
     return fd;
 }