Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: is '&' the right way to do this?
On 17 Dec 2019, at 06:33, TJ Luoma <luomat@xxxxxxxxx> wrote:
> ( find / -type f -print > /tmp/filelist.txt ) &
Technically you don't need the parentheses in this example
On 17 Dec 2019, at 06:33, TJ Luoma <luomat@xxxxxxxxx> wrote:
> Question #1: Would it be better for any reason to use `&|` such as:
> or is the use of `&|` really only beneficial for interactive shells?
When the MONITOR and HUP options are both enabled, the shell will
automatically send SIGHUP to all jobs in the job-control table when it shuts
down (which usually kills their processes). Disowning a background job with
&|, &!, or disown removes it from the job-control table, which prevents it
from receiving the signal
Since MONITOR is only enabled by default in interactive shells, the main
benefit of disowning doesn't usually apply in scripts. However, it doesn't
hurt anything either, and it may be useful in rare cases, e.g., where you
specifically want to exclude certain jobs from the job-control table
On 17 Dec 2019, at 06:33, TJ Luoma <luomat@xxxxxxxxx> wrote:
> Question #2: Are there better ways of doing this?
There are other options that you might use in some scenarios, like coproc and
nohup and setsid and even systemd, but & is probably fine for the general use
case of 'run a job asynchronously / in the background'. I think so, anyway
dana
Messages sorted by:
Reverse Date,
Date,
Thread,
Author