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 783951da990a5b7896e71fa976e57e301f9cfc91
parent a14f8e8ee4c96e0510a9a85dc3b11e661c68c263
Author: Natasha Kerensikova <natacha@instinctive.eu>
Date:   Fri, 14 Feb 2014 22:41:08 +0100

Move daemon(3) before kqueue(2)

The file descriptor returned by kqueue(2) is not inherited through
fork(2), which is used by daemon(3). For some unknown reason it
worked anyway in 9.1-RELEASE, which allowed the issue to escape
notice.

Diffstat:
Mfilewatcherd.c | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/filewatcherd.c b/filewatcherd.c @@ -146,6 +146,12 @@ main(int argc, char **argv) { return EXIT_FAILURE; log_watchtab_loaded(tabpath); + /* Fork to background */ + if (daemonize) { + daemon(0, 0); + set_report(&syslog); + } + /* Create a kernel queue */ kq = kqueue(); if (kq == -1) { @@ -164,12 +170,6 @@ main(int argc, char **argv) { return EXIT_FAILURE; } - /* Fork to background */ - if (daemonize) { - daemon(0, 0); - set_report(&syslog); - } - /* Insert initial watchers */ SLIST_FOREACH(wentry, &wtab, next) { insert_entry(kq, wentry);