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

Re: How to propagate SIGTERM to the foreground job, if any?



On 2024-04-20 21:09:46 -0700, Bart Schaefer wrote:
> > > > But then, why does "kill %%" work?
> > >
> > > It doesn't.
> >
> > Indeed, it doesn't, but %1 works
> 
> Except that %1 might be the wrong job number if there are any
> background jobs?

Yes, that's a potential issue, and that's why I would prefer %%.

> Why not do it like this?
> 
> setopt TRAPS_ASYNC
> echo $$
> trap 'kill $xterm; exit' TERM
> xterm & xterm=$!
> wait $xterm
> echo end

xterm was just a very simple example. In practice, several commands
are involved, and among them, there are zsh functions that may need
to affect the environment.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)




Messages sorted by: Reverse Date, Date, Thread, Author