Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: How to propagate SIGTERM to the foreground job, if any?
I think that I should start to test with something simpler, with
a command like
unison -sshcmd ~/scripts/ssh ~/testdir ssh://remote_host/testdir
For ~/scripts/ssh, the following works with I type Ctrl-C
when ssh-add asks for the passphrase:
------------------------------------------------------------
#!/usr/bin/env zsh
unset DISPLAY
setopt TRAPS_ASYNC
trap 'echo term >&2; kill %1; exit' TERM INT
ssh-add file1 file2 file3
echo end... >&2
exit
------------------------------------------------------------
But %1 might not be the right job in more complex cases.
BTW, I'm wondering why %1 works, but not %%.
Moreover "term" is output twice. Why?
The following, based on what you proposed, also works:
------------------------------------------------------------
#!/usr/bin/env zsh
unset DISPLAY
setopt TRAPS_ASYNC
trap 'echo term >&2; kill $e; exit' TERM INT
ssh-add file1 file2 file3 &
e=$!
wait $e
echo end... >&2
exit
------------------------------------------------------------
This time, "term" is output 1, 2 or 3 times.
But these solutions do not work when ssh-add is in a zsh function,
even in a simple case like:
f()
{
ssh-add file1 file2 file3
}
and use "f" instead of "ssh-add file1 file2 file3".
Is this a bug or is there any reason?
On 2024-04-21 17:41:38 -0700, Bart Schaefer wrote:
> Try this:
> trap 'setopt MONITOR HUP NOCHECKJOBS; exit' TERM
This doesn't work at all with the above test.
> > ssh-add file1 file2 file3 &
> >
> > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
> > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
> > ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory
>
> That's ... interesting. The error makes it look like ssh-askpass is
> what's not being found, but it's probably choking trying to open a
> terminal. I can think of some possible ways to fake it but perhaps
> with the above MONITOR tweak it isn't necessary.
I don't remember what I did exactly. These errors occur if DISPLAY
is set (with my usual wrapper, I unset DISPLAY, so that there may
be another cause).
--
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)
- References:
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
- Re: How to propagate SIGTERM to the foreground job, if any?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author