Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: job control from script



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