Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to propagate SIGTERM to the foreground job, if any?
- X-seq: zsh-users 29840
- From: Vincent Lefevre <vincent@xxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: How to propagate SIGTERM to the foreground job, if any?
- Date: Fri, 19 Apr 2024 23:32:25 +0200
- Archived-at: <https://zsh.org/users/29840>
- In-reply-to: <CAH+w=7atm3k6WwkhuywjPQC0eOB7W+3VvjWjR6jMk-JVExDpZQ@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- Mail-followup-to: zsh-users@xxxxxxx
- References: <20240419171752.GA48158@cventin.lip.ens-lyon.fr> <CAH+w=7a_CC-PE=XWjQfSfbNbQM3XX=TywXJoEf0mkD8_cKErmw@mail.gmail.com> <20240419190027.GA109916@joooj.vinc17.net> <CAH+w=7atm3k6WwkhuywjPQC0eOB7W+3VvjWjR6jMk-JVExDpZQ@mail.gmail.com>
On 2024-04-19 13:06:12 -0700, Bart Schaefer wrote:
> On Fri, Apr 19, 2024 at 12:00 PM Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> >
> > 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)
>
> I don't understand how you're determining that the leader is an ancestor.
>
> That you have job control at all implies this is an interactive shell.
> When zsh starts interactively, it attaches to the TTY and makes itself
> the group leader.
No, this is a script. You can test with
#!/usr/bin/env zsh
setopt TRAPS_ASYNC
echo $$
trap "trap - TERM; kill %1 $$" TERM
xterm
echo end
and type "kill <pid>" with the <pid> output by the script. This
kills both xterm and the script (no "end" output). Without the %1,
xterm isn't killed.
This shows that one can get the associated job of the foreground
command.
> > But then, why does "kill %%" work?
>
> It doesn't.
Indeed, it doesn't, but %1 works (this was what I actually tried,
and I thought I had tried %% too, which I actually did only with
${jobstates:+%%} I think).
--
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