Commit 1a9d614f authored by Cedric Roux's avatar Cedric Roux

take care of SIGPIPE received when writing a dead socket

write() on a socket with the other end closed throws a SIGPIPE.
Let's ignore this signal. write() will return an error anyway...
parent 83350a80
......@@ -9,6 +9,7 @@
#include <fcntl.h>
#include <pthread.h>
#include <inttypes.h>
#include <signal.h>
#include "T_defs.h"
#include "T_IDs.h"
......@@ -195,6 +196,7 @@ again:
dead:
/* socket died, let's stop all traces and wait for another tracer */
/* TODO: be careful with those write, they might write less than wanted */
buf[0] = 1;
if (write(to, buf, 1) != 1) abort();
len = T_NUMBER_OF_IDS;
......@@ -312,6 +314,9 @@ void T_local_tracer_main(int remote_port, int wait_for_tracer,
int dont_wait = wait_for_tracer ? 0 : 1;
void *f;
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
init_shm();
s = local_socket;
......
......@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "database.h"
#include "event.h"
#include "handler.h"
......@@ -246,6 +247,9 @@ int main(int n, char **v)
enb_gui eg;
enb_data enb_data;
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
on_off_name = malloc(n * sizeof(char *)); if (on_off_name == NULL) abort();
on_off_action = malloc(n * sizeof(int)); if (on_off_action == NULL) abort();
......
......@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "database.h"
#include "event.h"
#include "handler.h"
......@@ -93,6 +94,9 @@ int main(int n, char **v)
int gui_active = 1;
textlog_data textlog_data;
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
on_off_name = malloc(n * sizeof(char *)); if (on_off_name == NULL) abort();
on_off_action = malloc(n * sizeof(int)); if (on_off_action == NULL) abort();
......
......@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include <signal.h>
#include "database.h"
#include "event.h"
#include "handler.h"
......@@ -129,6 +130,9 @@ int main(int n, char **v)
gui *g;
vcd_data vcd_data;
/* write on a socket fails if the other end is closed and we get SIGPIPE */
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) abort();
on_off_name = malloc(n * sizeof(char *)); if (on_off_name == NULL) abort();
on_off_action = malloc(n * sizeof(int)); if (on_off_action == NULL) abort();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment