From 2819d11ceeb1ac739ed5f17ccb0abab63f494299 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sat, 2 Jan 2016 18:40:29 -0500 Subject: preliminary refactor of user data management --- src/client.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src/client.c') diff --git a/src/client.c b/src/client.c index 2784987..8591858 100644 --- a/src/client.c +++ b/src/client.c @@ -172,7 +172,9 @@ void sig_rt_0_handler(int s, siginfo_t *info, void *v) } unsigned char cmd; + /* drop this command */ read(from_parent, &cmd, 1); + switch(cmd) { case REQ_BCASTMSG: @@ -211,6 +213,18 @@ void sig_rt_0_handler(int s, siginfo_t *info, void *v) sigqueue(getppid(), SIGRTMIN+1, junk); } +static void sigpipe_handler(int s) +{ + (void) s; + union sigval junk; + /* + * necessary in case we get SIGPIPE in our SIGRTMIN+1 handler, + * the master expects a response from us + */ + sigqueue(getppid(), SIGRTMIN+1, junk); + _exit(0); +} + static void client_change_state(int state) { send_master(REQ_CHANGESTATE, &state, sizeof(state)); @@ -289,7 +303,9 @@ void client_main(int fd, struct sockaddr_in *addr, int total, int to, int from) output_locked = 0; struct sigaction sa; - sa.sa_handler = SIG_DFL; + sigemptyset(&sa.sa_mask); + sa.sa_handler = sigpipe_handler; + sa.sa_flags = SA_RESTART; if(sigaction(SIGPIPE, &sa, NULL) < 0) error("sigaction"); -- cgit v1.1