zsh-workers
 help / color / mirror / code / Atom feed
* zpty intermediate zsh process?
@ 2021-02-06 18:21 Greg Klanderman
  2021-02-06 21:53 ` Bart Schaefer
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Klanderman @ 2021-02-06 18:21 UTC (permalink / raw)
  To: Zsh list


I've been using the zpty module a bit lately and noticed I always get
an intermediate zsh process before the command run to start a zpty.
I can prefix the command with 'exec' to avoid that, but looking at the
code in zpty.c, maybe the execode() call should just be setting the
(third) 'exiting' argument to true?  Reading the comment above
execlist() it seems that should just DTRT?

cheers,
Greg


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zpty intermediate zsh process?
  2021-02-06 18:21 zpty intermediate zsh process? Greg Klanderman
@ 2021-02-06 21:53 ` Bart Schaefer
  2021-02-09  0:31   ` Greg Klanderman
  0 siblings, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2021-02-06 21:53 UTC (permalink / raw)
  To: Greg Klanderman; +Cc: Zsh list

On Sat, Feb 6, 2021 at 10:21 AM Greg Klanderman <gak@klanderman.net> wrote:
>
> I can prefix the command with 'exec' to avoid that, but looking at the
> code in zpty.c, maybe the execode() call should just be setting the
> (third) 'exiting' argument to true?

That doesn't seem to cause any of the tests to fail, but I wonder
about side effects when traps are enabled, especially the EXIT trap.

Maybe just passing !sigtrapped[SIGEXIT] as the third argument would
suffice ... or maybe the handling of that trap by zpty is already
iffy.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zpty intermediate zsh process?
  2021-02-06 21:53 ` Bart Schaefer
@ 2021-02-09  0:31   ` Greg Klanderman
  2021-02-09 17:43     ` Greg Klanderman
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Klanderman @ 2021-02-09  0:31 UTC (permalink / raw)
  To: zsh-workers

>>>>> On February 6, 2021 Bart Schaefer <schaefer@brasslantern.com> wrote:

> On Sat, Feb 6, 2021 at 10:21 AM Greg Klanderman <gak@klanderman.net> wrote:
>> 
>> I can prefix the command with 'exec' to avoid that, but looking at the
>> code in zpty.c, maybe the execode() call should just be setting the
>> (third) 'exiting' argument to true?

> That doesn't seem to cause any of the tests to fail, but I wonder
> about side effects when traps are enabled, especially the EXIT trap.

Hmm interesting, hadn't considered but I suppose the pty might even
just be executing zsh code.. I suppose this is not worth changing if
it might break desirable behavior.

> Maybe just passing !sigtrapped[SIGEXIT] as the third argument would
> suffice ... or maybe the handling of that trap by zpty is already
> iffy.

Reading zexit(), I suppose also "zshexit" and "zshexit_functions".

What is

    runhookdef(EXITHOOK, NULL);

?

Greg


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: zpty intermediate zsh process?
  2021-02-09  0:31   ` Greg Klanderman
@ 2021-02-09 17:43     ` Greg Klanderman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Klanderman @ 2021-02-09 17:43 UTC (permalink / raw)
  To: zsh-workers



>>>>> On February 8, 2021 Greg Klanderman <gak@klanderman.net> wrote:

>>>>> On February 6, 2021 Bart Schaefer <schaefer@brasslantern.com> wrote:
>> On Sat, Feb 6, 2021 at 10:21 AM Greg Klanderman <gak@klanderman.net> wrote:
>>> 
>>> I can prefix the command with 'exec' to avoid that, but looking at the
>>> code in zpty.c, maybe the execode() call should just be setting the
>>> (third) 'exiting' argument to true?

>> That doesn't seem to cause any of the tests to fail, but I wonder
>> about side effects when traps are enabled, especially the EXIT trap.

> Hmm interesting, hadn't considered but I suppose the pty might even
> just be executing zsh code.. I suppose this is not worth changing if
> it might break desirable behavior.

>> Maybe just passing !sigtrapped[SIGEXIT] as the third argument would
>> suffice ... or maybe the handling of that trap by zpty is already
>> iffy.

> Reading zexit(), I suppose also "zshexit" and "zshexit_functions".

> What is

>     runhookdef(EXITHOOK, NULL);

> ?

Relatedly, how would you feel about zpty returning the pid of the new
process in $!, like the zsh/clone module does?

Looks like it should just require adding

|    lastpid = pid;

somewhere after the brace closing 'else if (!pid) { ...'

Greg


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-02-09 17:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-06 18:21 zpty intermediate zsh process? Greg Klanderman
2021-02-06 21:53 ` Bart Schaefer
2021-02-09  0:31   ` Greg Klanderman
2021-02-09 17:43     ` Greg Klanderman

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