Make terminology more consistent and avoid some "kill child" usages

This commit is contained in:
Félix Saparelli 2021-04-11 03:21:38 +12:00
parent 12d130c3f1
commit 1b5bdee08e
No known key found for this signature in database
GPG Key ID: B948C4BAE44FC474
8 changed files with 22 additions and 18 deletions

View File

@ -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

View File

@ -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]'

View File

@ -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 <pattern>. This option can be specified multiple times, where a match on any given pattern causes the path to trigger <command>.
* `-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` <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` <pattern>:
Ignores modifications from paths that match <pattern>. 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 <pattern>. 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 <command> 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 <command>.

View File

@ -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")

View File

@ -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<String>,
/// 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,
}

View File

@ -30,7 +30,7 @@ impl From<io::Error> 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,

View File

@ -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);
}

View File

@ -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);