Fixed documentation

This commit is contained in:
2024-08-20 16:17:51 +02:00
parent 77f6db18a5
commit f83f8f034e
2 changed files with 8 additions and 7 deletions

View File

@@ -20,7 +20,7 @@ This command will produce a statically compiled binary called *wolf*.
``` ```
Wolf - Configurable file watchdog for Linux platform. Wolf - Configurable file watchdog for Linux platform.
Syntax: './wolf [-c|-d|-m|-r|-w|-p|-f] <PATH ...>' Syntax: './wolf [-c|-d|-m|-r|-w|-p|-f|-e] <PATH ...>'
options: options:
-c, --create | Add a watchdog for file creation -c, --create | Add a watchdog for file creation
-d, --delete | Add a watchdog for file deletion -d, --delete | Add a watchdog for file deletion
@@ -29,6 +29,7 @@ options:
-w, --write | Add a watchdog for writing events -w, --write | Add a watchdog for writing events
-p, --permission | Add a watchdog for permissions changes -p, --permission | Add a watchdog for permissions changes
-f, --full | Enable all the previous options -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 --no-timestamp | Disable timestamp from watchdog output
-v, --version | Show program version -v, --version | Show program version
-h, --help | Show this helper -h, --help | Show this helper
@@ -134,21 +135,21 @@ $> ./wolf -w --exec 'python foo.py'
4^2 = 16 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. spawns a new process.
## Technical details ## Technical details
Below there is a brief list of the things you should be aware of when using **Wolf**. 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 - 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; 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 - 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; 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 - 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. 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 - `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; 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 - `inotify` is quite verbose by design. For instance if you try to write to a **non-empty** watched file

4
wolf.c
View File

@@ -48,7 +48,7 @@ void sigint_handler() {
void helper(const char *name) { void helper(const char *name) {
printf("Wolf - Configurable file watchdog for Linux platform.\n\n" printf("Wolf - Configurable file watchdog for Linux platform.\n\n"
"Syntax: '%s [-c|-d|-m|-r|-w|-p|-f] <PATH ...>'\n" "Syntax: '%s [-c|-d|-m|-r|-w|-p|-f|-e] <PATH ...>'\n"
"options:\n" "options:\n"
"-c, --create | Add a watchdog for file creation\n" "-c, --create | Add a watchdog for file creation\n"
"-d, --delete | Add a watchdog for file deletion\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, " "); token = strtok(NULL, " ");
} }
// Null-terminate the string // Null-terminate argv, this is required by execvp
argv[idx] = NULL; argv[idx] = NULL;
// Clear temporary resources // Clear temporary resources
free(cmd_dup); free(cmd_dup);