From 212d8f424125cdd40c154b2f09a219d4d0325b8d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 3 Apr 2013 16:31:14 -0400 Subject: Use send() in client library to avoid SIGPIPE The client library lives in applications that may not be blocking or ignoring SIGPIPE. Using write() can cause SIGPIPE to be raised in the application if the proxy is restarted. If the application does not catch the signal then it is terminated. Make sure this does not happen by using send() with the MSG_NOSIGNAL flag. Signed-off-by: Simo Sorce --- proxy/src/client/gpm_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/src/client/gpm_common.c b/proxy/src/client/gpm_common.c index 80f487c..d9015f6 100644 --- a/proxy/src/client/gpm_common.c +++ b/proxy/src/client/gpm_common.c @@ -177,7 +177,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx, do { ret = 0; do { - wn = write(gpmctx->fd, &size, sizeof(uint32_t)); + wn = send(gpmctx->fd, &size, sizeof(uint32_t), MSG_NOSIGNAL); if (wn == -1) { ret = errno; } @@ -201,7 +201,7 @@ static int gpm_send_buffer(struct gpm_ctx *gpmctx, pos = 0; while (length > pos) { - wn = write(gpmctx->fd, buffer + pos, length - pos); + wn = send(gpmctx->fd, buffer + pos, length - pos, MSG_NOSIGNAL); if (wn == -1) { if (errno == EINTR) { continue; -- cgit