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-19 11:30:35 -0700, Bart Schaefer wrote:
> On Fri, Apr 19, 2024 at 10:18 AM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> > How to propagate SIGTERM to the foreground job, if any?
> 
> Hm ... if there's a foreground job, it should be the process group
> leader for the terminal (so as to receive TSTP and INT), so it might
> work just to do "kill 0 TERM"

I don't understand why you are saying that "it should be the process
group leader for the terminal". This is not true in my case (the
leader is some ancestor), and note that I do not want to kill the
whole process group.

> > setopt TRAPS_ASYNC
> > trap "trap - TERM; kill ${jobstates:+%%} $$" TERM
> >
> > But it seems that $jobstates is not available in the trap.
> 
> It's not that $jobstates is not available, it's that the foreground
> job isn't in the table at all.

But then, why does "kill %%" work?

Is there a way to know whether %% exists?

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