wendy

inotify based node watcher
git clone git://git.2f30.org/wendy
Log | Files | Refs | README | LICENSE

commit 914fb4ad0fa9e4e14541ccd0baf749c582e6227a
parent d23d7988ed57234856fc6c8633582bf147a743e0
Author: z3bra <willy@mailoo.org>
Date:   Mon, 15 Jun 2015 00:12:09 +0200

added double forking to avoid zombie children

Diffstat:
Mwendy.c | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/wendy.c b/wendy.c @@ -21,6 +21,7 @@ #include <linux/limits.h> #include <string.h> #include <sys/inotify.h> +#include <sys/wait.h> /* definitions, defaults, bla bla blah */ #define EVENT_SIZE (sizeof(struct inotify_event)) @@ -252,8 +253,14 @@ main (int argc, char **argv) * Me neither. Just trust the if(). */ if (cmd) { - /* OMG a new event ! Quick, raise an alert ! */ - if (!fork()) { execvpe(cmd[0], cmd, environ); } + /* + * OMG a new event! raise an alert! + * Also, double-forking. + */ + if (!fork()) + if (!fork()) execvpe(cmd[0], cmd, environ); + else exit(0); + else wait(NULL); } /* jump to the next one */