diff --git a/README.md b/README.md index 44329b0..cd0d004 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This command will produce a statically compiled binary called *wolf*. ``` Wolf - Configurable file watchdog for Linux platform. -Syntax: './wolf [-c|-d|-m|-r|-w|-p|-f] ' +Syntax: './wolf [-c|-d|-m|-r|-w|-p|-f|-e] ' options: -c, --create | Add a watchdog for file creation -d, --delete | Add a watchdog for file deletion @@ -29,6 +29,7 @@ options: -w, --write | Add a watchdog for writing events -p, --permission | Add a watchdog for permissions changes -f, --full | Enable all the previous options +-e, --exec | Execute a command when a watchdog detects a change --no-timestamp | Disable timestamp from watchdog output -v, --version | Show program version -h, --help | Show this helper @@ -134,21 +135,21 @@ $> ./wolf -w --exec 'python foo.py' 4^2 = 16 ``` -Be sure to read the _caveats_ section to learn more about the concurrent aspects of this feature and how **Wolf** +Be sure to read the _"technical details"_ section to learn more about the concurrent aspects of this feature and how **Wolf** spawns a new process. ## Technical details Below there is a brief list of the things you should be aware of when using **Wolf**. -- `inotify` is **NOT** recursive. Meaning that you cannot monitor subdirectories of a watched directory; -- `inotify` can only work within files for which you already have reading and writing permissions; - The `-e,--exec` option works by spawning a child process using the `fork(2)` system call; thus, the command is being executed in a new process; - The `-e,--exec` option is a **NON-BLOCKING** feature, meaning that the parent process will continue to log new changes while the child process execute the supplied command; therefore the parent process will **NOT** wait for the child(s) process to terminate; - Since the parent process does not await for the child process to complete it will also not handle its return code, thus the exit status of any supplied command is ignored. -- Any `SIGCHLD` signal generated by a child process is ignored, therefore the process reaping of any child is delegated to the kernel; +- Any `SIGCHLD` signal generated by a child process is ignored, therefore the reaping of any child process is delegated to the kernel; +- `inotify` is **NOT** recursive. Meaning that you cannot monitor subdirectories of a watched directory; +- `inotify` can only work within files for which you already have reading and writing permissions; - `inotify` removes deleted files from the `inotify_add_watch(2)`, meaning that, after a file is being deleted, the watchdog associated with it is automatically removed as well. To add it again, the program has to be restarted; - `inotify` is quite verbose by design. For instance if you try to write to a **non-empty** watched file diff --git a/wolf.c b/wolf.c index 733f9dd..ce34614 100644 --- a/wolf.c +++ b/wolf.c @@ -48,7 +48,7 @@ void sigint_handler() { void helper(const char *name) { printf("Wolf - Configurable file watchdog for Linux platform.\n\n" - "Syntax: '%s [-c|-d|-m|-r|-w|-p|-f] '\n" + "Syntax: '%s [-c|-d|-m|-r|-w|-p|-f|-e] '\n" "options:\n" "-c, --create | Add a watchdog for file creation\n" "-d, --delete | Add a watchdog for file deletion\n" @@ -376,7 +376,7 @@ static uint8_t **tokenize_command(const char *cmd) { token = strtok(NULL, " "); } - // Null-terminate the string + // Null-terminate argv, this is required by execvp argv[idx] = NULL; // Clear temporary resources free(cmd_dup);