summaryrefslogtreecommitdiffstats
path: root/xrdpapi/xrdpapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'xrdpapi/xrdpapi.c')
-rw-r--r--xrdpapi/xrdpapi.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/xrdpapi/xrdpapi.c b/xrdpapi/xrdpapi.c
index 7e9eaa0c..974a094c 100644
--- a/xrdpapi/xrdpapi.c
+++ b/xrdpapi/xrdpapi.c
@@ -126,7 +126,7 @@ WTSVirtualChannelOpenEx(unsigned int SessionId, const char *pVirtualName,
/* we use unix domain socket to communicate with chansrv */
if ((wts->fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
{
- g_free(wts);
+ free(wts);
return NULL;
}
@@ -162,6 +162,14 @@ WTSVirtualChannelOpenEx(unsigned int SessionId, const char *pVirtualName,
return wts;
}
+/*
+ * Prevent receiving SIGPIPE on disconnect using either MSG_NOSIGNAL (Linux)
+ * or SO_NOSIGPIPE (Mac OS X)
+ */
+#if !defined(MSG_NOSIGNAL)
+#define MSG_NOSIGNAL 0
+#endif
+
/*****************************************************************************/
static int
mysend(int sck, const void* adata, int bytes)
@@ -170,6 +178,11 @@ mysend(int sck, const void* adata, int bytes)
int error;
const char* data;
+#if defined(SO_NOSIGPIPE)
+ const int on = 1;
+ setsockopt(sck, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on));
+#endif
+
data = (const char*)adata;
sent = 0;
while (sent < bytes)