From 714601393f7369e62b4fcb32516f2188f8545b68 Mon Sep 17 00:00:00 2001 From: Anatolii Nikulin Date: Wed, 25 Nov 2015 14:51:10 +0300 Subject: [FIX] disable signal SIGPIPE Use flag MSG_NOSIGNAL in send() to supress signal SIGPIPE when send message to socket, closed by other side Change-Id: I0c4bfe90ded211f55fc5eebf5c4e4223d9d47a9f Signed-off-by: Anatolii Nikulin --- helper/libdaprobe.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helper/libdaprobe.c b/helper/libdaprobe.c index 7f349a9..16be7ef 100755 --- a/helper/libdaprobe.c +++ b/helper/libdaprobe.c @@ -611,7 +611,7 @@ bool printLog(log_t *log, int msgType) len = sizeof(log->type) + sizeof(log->length) + log->length; real_pthread_mutex_lock(&(gTraceInfo.socket.sockMutex)); - res = send(gTraceInfo.socket.daemonSock, log, len, 0); + res = send(gTraceInfo.socket.daemonSock, log, len, MSG_NOSIGNAL); real_pthread_mutex_unlock(&(gTraceInfo.socket.sockMutex)); return (res == len); @@ -645,7 +645,7 @@ bool print_log_str(int msgType, char *str) /* lock socket and send */ real_pthread_mutex_lock(&(gTraceInfo.socket.sockMutex)); - res = send(gTraceInfo.socket.daemonSock, &log, len, 0); + res = send(gTraceInfo.socket.daemonSock, &log, len, MSG_NOSIGNAL); real_pthread_mutex_unlock(&(gTraceInfo.socket.sockMutex)); return (res == len); @@ -702,7 +702,8 @@ bool print_log_fmt(int msgType, const char *func_name, int line, ...) real_pthread_mutex_lock(&(gTraceInfo.socket.sockMutex)); if(unlikely(gTraceInfo.socket.daemonSock != -1)) { - res = send(gTraceInfo.socket.daemonSock, &log, len, MSG_DONTWAIT); + res = send(gTraceInfo.socket.daemonSock, &log, len, + MSG_DONTWAIT | MSG_NOSIGNAL); } else { /* if socket is not connected, out to stderr */ fprintf(stderr, "%s %s\n", msg_code_to_srt(msgType), log.data); -- cgit v1.2.3