Fixed child process bug and updated documentation

This commit is contained in:
2025-07-21 16:08:49 +02:00
parent f83f8f034e
commit 19a6deac95
4 changed files with 45 additions and 20 deletions

View File

@@ -1,4 +1,4 @@
# Wolf 🐺
# Wolf 🐺 [![](https://github.com/ceticamarco/wolf/actions/workflows/wolf.yml/badge.svg)](https://github.com/ceticamarco/wolf/actions/workflows/wolf.yml)
**Wolf** is a configurable file watchdog for Linux platform written in C. **Wolf** monitors
a set of files or directories and prints out a log event each time the watched resources changes. The watchdog
@@ -34,7 +34,7 @@ options:
-v, --version | Show program version
-h, --help | Show this helper
General help with the software: https://git.marcocetica.com/marco/wolf
Project homepage: https://github.com/ceticamarco/wolf
Report bugs to: Marco Cetica(<email@marcocetica.com>)
```
@@ -103,7 +103,8 @@ P '/home/marco/wolf/a.out' (file)
W '/home/marco/wolf/a.out' (file)
```
Additionally, if you want to execute a custom command every time a watchdog detects a change, you can do so by
using the `-e,--exec` option. For instance, suppose that you have a Python file(`foo.py`) with the following content:
using the `-e,--exec` option. For instance, suppose that you have a Python file(`foo.py`) on the current directory
with the following content:
```py
def square(x):
@@ -116,14 +117,14 @@ and you want to continously evaluate it as soon as you save it to the disk. To d
below:
```sh
$> ./wolf -w --exec 'python foo.py'
$> ./wolf -w --exec 'python foo.py' .
```
Each time a write event is detected by the watchdog, the supplied command will be issued, causing the program
to be automatically evaluated, that is:
```sh
$> ./wolf -w --exec 'python foo.py'
$> ./wolf -w --exec 'python foo.py' .
[2024-08-20 16:24:43] W 'foo.py' (file)
10^2 = 100
[2024-08-20 16:24:55] W 'foo.py' (file)
@@ -143,11 +144,9 @@ Below there is a brief list of the things you should be aware of when using **Wo
- 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 reaping of any child process is delegated to the kernel;
- The `-e,--exec` option is a **BLOCKING** feature, meaning that the parent process waits for the child process to terminate
before logging new changes;
- The child's return code will be printed to standard output only if it is non-zero or if the child was terminated by a signal;
- `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