Repository : ssh://git@open-mesh.org/alfred
On branch : master
---------------------------------------------------------------
commit 27aee5246d49ea2d08565a35fdc2e59f3ab7b5df
Author: Simon Wunderlich <simon(a)open-mesh.com>
Date: Thu Feb 21 11:21:50 2013 +0100
alfred: handle sigpipe
Otherwise alfred might exit when a SIGPIPE occurs, e.g. when writing
to a client which has already closed his side of the socket.
Reported-by: Antonio Quartulli <antonio(a)open-mesh.com>
Signed-off-by: Simon Wunderlich <simon(a)open-mesh.com>
---------------------------------------------------------------
27aee5246d49ea2d08565a35fdc2e59f3ab7b5df
main.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/main.c b/main.c
index c3bef57..86acfb7 100644
--- a/main.c
+++ b/main.c
@@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <sys/select.h>
#include <sys/time.h>
+#include <signal.h>
#include "alfred.h"
static void alfred_usage(void)
@@ -132,6 +133,9 @@ static struct globals *alfred_init(int argc, char *argv[])
return NULL;
}
}
+
+ if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
+ fprintf(stderr, "could not register SIGPIPE handler\n");
return globals;
}