Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: job control from script
- X-seq: zsh-users 9776
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: job control from script
- Date: Sun, 11 Dec 2005 19:58:39 +0000
- In-reply-to: <20051211172135.0f1caefc.rgo@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20051211172135.0f1caefc.rgo@xxxxxxxxxxxxxxxx>
On Dec 11, 5:21pm, rgo wrote:
}
} Why `kill %' doesn't work?
What do you expect it to do, and why?
There's no job specifier that means "all jobs". I've tried both bash and
ksh and "kill %" in those shells kills exactly one job (the most recent
one, as if "kill %+"). Zsh is the same.
} And `kill %NUM'? And how can I fetch job list for use in script?
You can either
zmodload zsh/parameter
kill %${(k)^jobstates}
or (if your version of zsh is recent enough that piping the jobs command
produces useful output) use
jobs -p | while read jnum jpid text; do kill $jpid; done
The easiest thing, though, might be
setopt MONITOR HUP
function TRAPINT() { kill -HUP $$ }
which just says that on an INTerrupt, send a HUP signal, which will then
automatically be propagated to all the child processes.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author