From 1b5bdee08ed733f4416c481ab41b872a53eb1995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Saparelli?= Date: Sun, 11 Apr 2021 03:21:38 +1200 Subject: [PATCH] Make terminology more consistent and avoid some "kill child" usages --- README.md | 8 ++++---- completions/zsh | 2 +- doc/watchexec.1.ronn | 9 ++++++--- src/args.rs | 2 +- src/config.rs | 7 ++++--- src/error.rs | 2 +- src/process.rs | 2 +- src/run.rs | 8 ++++---- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 30021a9..53b037e 100644 --- a/README.md +++ b/README.md @@ -23,8 +23,8 @@ Example use cases: * By default, uses `.gitignore` and `.ignore` to determine which files to ignore notifications for * Support for watching files with a specific extension * Support for filtering/ignoring events based on [glob patterns](https://docs.rs/globset/*/globset/#syntax) -* Launches child processes in a new process group -* Sets the following environment variables in the child process: +* Launches the command in a new process group +* Sets the following environment variables in the process: * If a single file changed (depending on the event type): * `$WATCHEXEC_CREATED_PATH`, the path of the file that was created * `$WATCHEXEC_REMOVED_PATH`, the path of the file that was removed @@ -61,11 +61,11 @@ Call/restart `python server.py` when any Python file in the current directory (a $ watchexec -e py -r python server.py -Call/restart `my_server` when any file in the current directory (and all subdirectories) changes, sending `SIGKILL` to stop the child process: +Call/restart `my_server` when any file in the current directory (and all subdirectories) changes, sending `SIGKILL` to stop the command: $ watchexec -r -s SIGKILL my_server -Send a SIGHUP to the child process upon changes (Note: using `-n` here we're executing `my_server` directly, instead of wrapping it in a shell: +Send a SIGHUP to the command upon changes (Note: using `-n` here we're executing `my_server` directly, instead of wrapping it in a shell: $ watchexec -n -s SIGHUP my_server diff --git a/completions/zsh b/completions/zsh index 7265c3b..628b1dc 100644 --- a/completions/zsh +++ b/completions/zsh @@ -14,7 +14,7 @@ args=( '--shell=[Change the wrapping shell, or `none` to disable]' '--no-shell[Deprecated, use --shell=none]' '-n[Shorthand for --shell=none]' - '--no-environment[Do not set WATCHEXEC_*_PATH environment variables for child process]' + '--no-environment[Do not set WATCHEXEC_*_PATH environment variables for command]' '--no-meta[Ignore metadata changes]' '(-p --postpone)'{-p,--postpone}'[Wait until first change to execute command]' '(-r --restart)'{-r,--restart}'[Restart the process if it''s still running]' diff --git a/doc/watchexec.1.ronn b/doc/watchexec.1.ronn index 39943e7..c498048 100644 --- a/doc/watchexec.1.ronn +++ b/doc/watchexec.1.ronn @@ -23,7 +23,7 @@ Comma-separated list of file extensions to filter by. Leading dots (.rs) are all Ignores modifications from paths that do not match . This option can be specified multiple times, where a match on any given pattern causes the path to trigger . * `-s`, `--signal`: -Sends the specified signal (e.g. `SIGKILL`) to the child process. Defaults to `SIGTERM`. +Sends the specified signal (e.g. `SIGKILL`) to the command. Defaults to `SIGTERM`. * `--shell` : Change the shell used to run the command. Set to `none` to run the command directly without a shell. @@ -42,7 +42,7 @@ Shorthand for `--shell=none`. Ignore metadata changes. * `--no-environment`: -Do not set WATCHEXEC_*_PATH environment variables for child process. +Do not set WATCHEXEC_*_PATH environment variables for the command. * `-i`, `--ignore` : Ignores modifications from paths that match . This option can be specified multiple times, and a match on any pattern causes the path to be ignored. @@ -51,7 +51,10 @@ Ignores modifications from paths that match . This option can be specif Monitor a specific path for changes. By default, the current working directory is watched. This may be specified multiple times, where a change in any watched directory (and subdirectories) causes to be executed. * `-r`, `--restart`: -Terminates the child process group if it is still running when subsequent file modifications are detected. By default, sends `SIGTERM`; use `--signal` to change that. +Terminates the command if it is still running when subsequent file modifications are detected. By default, sends `SIGTERM`; use `--signal` to change that. + +* `-W`, `--watch-when-idle`: +Ignore events while the process is still running. * `-c`, `--clear`: Clears the screen before executing . diff --git a/src/args.rs b/src/args.rs index 23d3e2e..1a8e4d3 100644 --- a/src/args.rs +++ b/src/args.rs @@ -126,7 +126,7 @@ where .help("Ignore metadata changes") .long("no-meta")) .arg(Arg::with_name("no-environment") - .help("Do not set WATCHEXEC_*_PATH environment variables for child process") + .help("Do not set WATCHEXEC_*_PATH environment variables for the command") .long("no-environment")) .arg(Arg::with_name("once").short("1").hidden(true)) .arg(Arg::with_name("watch-when-idle") diff --git a/src/config.rs b/src/config.rs index e52a8b3..0bc3eef 100644 --- a/src/config.rs +++ b/src/config.rs @@ -36,10 +36,10 @@ pub struct Config { /// Clear the screen before each run. #[builder(default)] pub clear_screen: bool, - /// If Some, send that signal (e.g. SIGHUP) to the child on change. + /// If Some, send that signal (e.g. SIGHUP) to the command on change. #[builder(default)] pub signal: Option, - /// If true, kill the child if it's still running when a change comes in. + /// If true, kill the command if it's still running when a change comes in. #[builder(default)] pub restart: bool, /// Interval to debounce the changes. (milliseconds) @@ -54,7 +54,7 @@ pub struct Config { /// Ignore metadata changes. #[builder(default)] pub no_meta: bool, - /// Do not set WATCHEXEC_*_PATH environment variables for child process. + /// Do not set WATCHEXEC_*_PATH environment variables for the process. #[builder(default)] pub no_environment: bool, /// Skip auto-loading .gitignore files @@ -74,6 +74,7 @@ pub struct Config { /// Interval for polling. (milliseconds) #[builder(default = "1000")] pub poll_interval: u32, + /// Ignore events emitted while the command is running. #[builder(default)] pub watch_when_idle: bool, } diff --git a/src/error.rs b/src/error.rs index 3555ad6..6038e5d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -30,7 +30,7 @@ impl From for Error { Self::Io(match err.raw_os_error() { Some(os_err) => match os_err { 7 => { - let msg = "There are so many changed files that the environment variables of the child process have been overrun. Try running with --no-meta or --no-environment."; + let msg = "There are so many changed files that the environment variables of the command have been overrun. Try running with --no-meta or --no-environment."; io::Error::new(io::ErrorKind::Other, msg) } _ => err, diff --git a/src/process.rs b/src/process.rs index 6031eb8..82ce63a 100644 --- a/src/process.rs +++ b/src/process.rs @@ -157,7 +157,7 @@ mod imp { use crate::signal::ConvertToLibc; let signo = signal.convert_to_libc(); - debug!("Sending {:?} (int: {}) to child process", signal, signo); + debug!("Sending {:?} (int: {}) to the command", signal, signo); self.c_signal(signo); } diff --git a/src/run.rs b/src/run.rs index 10b9e4c..0f9632d 100644 --- a/src/run.rs +++ b/src/run.rs @@ -168,7 +168,7 @@ impl ExecHandler { clear_screen(); } - debug!("Launching child process"); + debug!("Launching command"); let mut guard = self.child_process.write()?; *guard = Some(process::spawn( &self.args.cmd, @@ -219,11 +219,11 @@ impl Handler for ExecHandler { } // SIGHUP scenario: --signal was given, but --restart was not - // Just send a signal (e.g. SIGHUP) to the child, do nothing more + // Just send a signal (e.g. SIGHUP) to the command, do nothing more (true, false, Some(signal), _) => signal_process(&self.child_process, signal), // Custom restart behaviour (--restart was given, and --signal specified): - // Send specified signal to the child, wait for it to exit, then run the command again + // Send specified signal to the command, wait for it to exit, then run the command again (_, true, Some(signal), false) => { signal_process(&self.child_process, signal); wait_on_process(&self.child_process); @@ -231,7 +231,7 @@ impl Handler for ExecHandler { } // Default restart behaviour (--restart was given, but --signal wasn't specified): - // Send SIGTERM to the child, wait for it to exit, then run the command again + // Send SIGTERM to the command, wait for it to exit, then run the command again (_, true, None, false) => { signal_process(&self.child_process, Signal::SIGTERM); wait_on_process(&self.child_process);