filewatcherd

FreeBSD daemon that watches files and runs commands when they change
git clone https://git.instinctive.eu/filewatcherd.git
Log | Files | Refs | README | LICENSE

commit 95358273bd1894988668af99ab75040b782503d4
parent 783951da990a5b7896e71fa976e57e301f9cfc91
Author: Marcin Wolny <mwolny@wutanic.com>
Date:   Fri, 25 Jul 2014 13:41:38 +0200

Add SIGCHLD handler

  When process from run_entry() dies with an error it leaves process
  in ^Z state.

Diffstat:
Mfilewatcherd.c | 6++++++
Mlog.c | 8++++++++
Mlog.h | 4++++
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);