commit db0d32a5f480449fb9f040b89d0d89366e761d22
parent 783951da990a5b7896e71fa976e57e301f9cfc91
Author: Natasha Kerensikova <natgh@instinctive.eu>
Date: Sat, 26 Jul 2014 22:41:20 +0200
Merge pull request #1 from mwolny/master
Add SIGCHLD handler
Diffstat:
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/filewatcherd.c b/filewatcherd.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
+#include <signal.h>
#include <sys/types.h>
#include <sys/event.h>
@@ -130,6 +131,11 @@ main(int argc, char **argv) {
* INITIALIZATION *
******************/
+ if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
+ log_signal(SIGCHLD);
+ return EXIT_FAILURE;
+ }
+
/* Try to open and read the watchtab */
tab_fd = open(tabpath, O_RDONLY | O_CLOEXEC);
if (tab_fd < 0) {
diff --git a/log.c b/log.c
@@ -245,6 +245,14 @@ log_setuid(uid_t uid) {
}
+/* log_signal - signal() failed */
+void
+log_signal(int sig) {
+ report(LOG_ERR, "Unable to setup signal handler for \"%s\": %s",
+ strsignal(sig), strerror(errno));
+}
+
+
/* log_watchtab_invalid_action - invalid action line in watchtab */
void
log_watchtab_invalid_action(const char *filename, unsigned line_no) {
diff --git a/log.h b/log.h
@@ -143,6 +143,10 @@ log_setgid(gid_t gid);
void
log_setuid(uid_t uid);
+/* log_signal - signal() failed */
+void
+log_signal(int sig);
+
/* log_watchtab_invalid_action - invalid action line in watchtab */
void
log_watchtab_invalid_action(const char *filename, unsigned line_no);