From a4c5beadd3d444f31dd8109e329b570dbbc96209 Mon Sep 17 00:00:00 2001 From: Emil Renner Berthing Date: Mon, 3 Jun 2013 13:01:02 +0200 Subject: set EV_SIGNAL_ENABLE and EV_CHILD_ENABLE to prepare for upcoming signal library and reap child processes even when EV_CHILD_ENABLE is not set --- bin/lem.c | 24 ++++++++++++------------ ev-config.h.in | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bin/lem.c b/bin/lem.c index 395dbe8..4da67e0 100644 --- a/bin/lem.c +++ b/bin/lem.c @@ -94,21 +94,17 @@ lem_xmalloc(size_t size) } static int -ignore_sigpipe(void) +setsignal(int signal, void (*handler)(int), int flags) { struct sigaction act; - if (sigaction(SIGPIPE, NULL, &act)) { - lem_log_error("lem: error getting signal action: %s", - strerror(errno)); - return -1; - } + act.sa_handler = handler; + sigemptyset(&act.sa_mask); + act.sa_flags = flags; - act.sa_handler = SIG_IGN; - - if (sigaction(SIGPIPE, &act, NULL)) { - lem_log_error("lem: error setting signal action: %s", - strerror(errno)); + if (sigaction(signal, &act, NULL)) { + lem_log_error("lem: error setting signal %d: %s", + signal, strerror(errno)); return -1; } @@ -340,7 +336,11 @@ main(int argc, char *argv[]) return EXIT_FAILURE; } - if (ignore_sigpipe()) + if (setsignal(SIGPIPE, SIG_IGN, 0) +#if !EV_CHILD_ENABLE + || setsignal(SIGCHLD, SIG_DFL, SA_NOCLDSTOP | SA_NOCLDWAIT) +#endif + ) goto error; /* create main Lua state */ diff --git a/ev-config.h.in b/ev-config.h.in index 0952722..38324d3 100644 --- a/ev-config.h.in +++ b/ev-config.h.in @@ -35,9 +35,9 @@ #define EV_PREPARE_ENABLE 0 #define EV_CHECK_ENABLE 0 #define EV_FORK_ENABLE 0 -#define EV_SIGNAL_ENABLE 0 +#define EV_SIGNAL_ENABLE 1 #define EV_ASYNC_ENABLE 1 -#define EV_CHILD_ENABLE 0 +#define EV_CHILD_ENABLE 1 #define EV_MINPRI 0 #define EV_MAXPRI 0 -- cgit v1.2.1