zsh-workers
 help / color / mirror / 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

zsh-workers

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/zsh-workers

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 zsh-workers zsh-workers/ http://inbox.vuxu.org/zsh-workers \
		zsh-workers@zsh.org
	public-inbox-index zsh-workers

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/zsh/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git