* Weird interaction between zpty and trap
@ 2023-03-22 4:49 Felipe Contreras
2023-03-22 22:06 ` Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2023-03-22 4:49 UTC (permalink / raw)
To: Zsh hackers list
Hi,
Playing around with zpty I noticed some error messages coming
seemingly out of nowhere until I realized there was a trap.
Should the command executed by zpty keep the EXIT trap?
zmodload zsh/zpty
exec 3>&2
die() { echo >&3 "die"; }
trap 'die' EXIT
zpty c ':'
trap - EXIT
--
Felipe Contreras
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Weird interaction between zpty and trap
2023-03-22 4:49 Weird interaction between zpty and trap Felipe Contreras
@ 2023-03-22 22:06 ` Bart Schaefer
2023-03-22 23:07 ` Felipe Contreras
0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2023-03-22 22:06 UTC (permalink / raw)
To: Felipe Contreras; +Cc: Zsh hackers list
On Tue, Mar 21, 2023 at 9:50 PM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> Should the command executed by zpty keep the EXIT trap?
Tough call. It's technically a subshell, so by that distinction it
should follow the rules for subshells.
Aside, I never really thought about it before, but why wasn't zpty
implemented using the clone module? Just to avoid a dependency?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Weird interaction between zpty and trap
2023-03-22 22:06 ` Bart Schaefer
@ 2023-03-22 23:07 ` Felipe Contreras
2023-03-27 21:12 ` Felipe Contreras
0 siblings, 1 reply; 4+ messages in thread
From: Felipe Contreras @ 2023-03-22 23:07 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
On Wed, Mar 22, 2023 at 4:06 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Tue, Mar 21, 2023 at 9:50 PM Felipe Contreras
> <felipe.contreras@gmail.com> wrote:
> >
> > Should the command executed by zpty keep the EXIT trap?
>
> Tough call. It's technically a subshell, so by that distinction it
> should follow the rules for subshells.
The documentation of trap says:
ZERR and DEBUG traps are kept within subshells, while other traps are reset.
That sounds like EXIT should be reset.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Weird interaction between zpty and trap
2023-03-22 23:07 ` Felipe Contreras
@ 2023-03-27 21:12 ` Felipe Contreras
0 siblings, 0 replies; 4+ messages in thread
From: Felipe Contreras @ 2023-03-27 21:12 UTC (permalink / raw)
To: Bart Schaefer; +Cc: Zsh hackers list
On Wed, Mar 22, 2023 at 5:07 PM Felipe Contreras
<felipe.contreras@gmail.com> wrote:
>
> On Wed, Mar 22, 2023 at 4:06 PM Bart Schaefer <schaefer@brasslantern.com> wrote:
> >
> > On Tue, Mar 21, 2023 at 9:50 PM Felipe Contreras
> > <felipe.contreras@gmail.com> wrote:
> > >
> > > Should the command executed by zpty keep the EXIT trap?
> >
> > Tough call. It's technically a subshell, so by that distinction it
> > should follow the rules for subshells.
>
> The documentation of trap says:
>
> ZERR and DEBUG traps are kept within subshells, while other traps are reset.
>
> That sounds like EXIT should be reset.
OK. I'm just going to assume it's a bug in zsh I'll have to workaround
by removing the EXIT trap manually every time inside the zpty
subshell.
--
Felipe Contreras
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-27 21:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22 4:49 Weird interaction between zpty and trap Felipe Contreras
2023-03-22 22:06 ` Bart Schaefer
2023-03-22 23:07 ` Felipe Contreras
2023-03-27 21:12 ` Felipe Contreras
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).