\r
#ifndef MINGW\r
/**\r
- * Make a non-inheritable to child processes\r
+ * Make a socket non-inheritable to child processes\r
*\r
* @param h the socket to make non-inheritable\r
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise\r
\r
\r
\r
+#ifdef OSX\r
+/**\r
+ * The MSG_NOSIGNAL equivalent on Mac OS X\r
+ *\r
+ * @param h the socket to make non-delaying\r
+ */\r
+static void\r
+socket_set_nosigpipe (const struct GNUNET_NETWORK_Handle\r
+ *h)\r
+{\r
+ int value = 1;\r
+ setsockopt (h->fd, SOL_SOCKET, SO_NOSIGPIPE, &value, sizeof(value));\r
+}\r
+#endif\r
+\r
+\r
+\r
/**\r
* Disable delays when sending data via the socket.\r
* (GNUnet makes sure that messages are as big as\r
if (GNUNET_OK != socket_set_inheritable (ret))\r
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,\r
"socket_set_inheritable");\r
+#endif\r
+#ifdef OSX\r
+ socket_set_nosigpipe (ret); \r
#endif\r
socket_set_nodelay (ret);\r
return ret;\r
{\r
int ret;\r
int flags;\r
-#ifdef OSX\r
- int no_sigpipe;\r
- no_sigpipe = 1;\r
- /* shouldn't matter if this fails as there's a SIGPIPE handler */\r
- ret = setsockopt (desc->fd, SOL_SOCKET, SO_NOSIGPIPE,\r
- (void *) &no_sigpipe, sizeof (no_sigpipe));\r
-#endif\r
\r
flags = 0;\r
#ifdef MSG_DONTWAIT\r
{\r
int ret;\r
int flags;\r
-#ifdef OSX\r
- int no_sigpipe;\r
- no_sigpipe = 1;\r
- /* shouldn't matter if this fails as there's a SIGPIPE handler */\r
- ret = setsockopt (desc->fd, SOL_SOCKET, SO_NOSIGPIPE,\r
- (void *) &no_sigpipe, sizeof (no_sigpipe));\r
-#endif\r
\r
flags = 0;\r
#ifdef MSG_DONTWAIT\r
if (GNUNET_OK != socket_set_inheritable (ret))\r
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK,\r
"socket_set_inheritable");\r
+#endif\r
+#ifdef OSX\r
+ socket_set_nosigpipe (ret); \r
#endif\r
if (type == SOCK_STREAM)\r
socket_set_nodelay (ret);\r