zsh-users
 help / color / mirror / code / Atom feed
* Reverting the effect of 'setopt nomonitor' executed during shell startup
@ 2022-01-14 14:07 Andreas Hartmann
  2022-01-14 14:27 ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Hartmann @ 2022-01-14 14:07 UTC (permalink / raw)
  To: zsh-users

Hello,


I'm currently fighting with some zsh behavior that I can't quite explain to
myself. I use zplug along with zsh, and I believe that whenever zplug calls
'setopt nomonitor' during its setup, any subsequent call to e.g. `stty icanon`
will suspend the shell with a SIGTTOU. At least if I comment out calls to 'setopt
nomonitor' in zplugs startup, this behavior doesn't occur.

This change in shell options is so persistent in fact, that even passing "setopt
monitor" to negate the effect along in the same command doesn't change this
behavior back to the unmodified one. Using setopt I can see that this is the only
change performed to the shell, and furthermore no changes are applied to the stty
(like `stty nostop`, which has the same effect).

Here's a minimal working example (if you use zplug it works, can't reproduce it
without zplug and I don't know why...):

  #!/usr/bin/zsh
  
  /usr/bin/zsh -i -c "echo foo;"
  stty icanon
  echo "bar"

If you run this script it will become suspended upon calling `stty icanon`.
`icanon` here is just one of many options, I think pretty much any argument to
stty will work for that matter...

Is there a way to "fix" options at shell startup such that they cannot ever be
overwritten from within the shell? Or has someone else experienced this already
and knows how to mitigate it?


Thank you in advance!

Best,
hartan


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

* Re: Reverting the effect of 'setopt nomonitor' executed during shell startup
  2022-01-14 14:07 Reverting the effect of 'setopt nomonitor' executed during shell startup Andreas Hartmann
@ 2022-01-14 14:27 ` Roman Perepelitsa
  2022-01-14 17:26   ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2022-01-14 14:27 UTC (permalink / raw)
  To: Andreas Hartmann; +Cc: Zsh Users

On Fri, Jan 14, 2022 at 3:08 PM Andreas Hartmann <hartan@7x.de> wrote:
>
> Here's a minimal working example (if you use zplug it works, can't reproduce it
> without zplug and I don't know why...):
>
>   #!/usr/bin/zsh
>
>   /usr/bin/zsh -i -c "echo foo;"
>   stty icanon
>   echo "bar"

Reproduced like this:

  % >test.zsh <<\END
  zsh -fic "unsetopt monitor"
  stty icanon
  END

  % zsh -f ./test.zsh
  zsh: suspended (tty output)  zsh ./test.zsh

Another way to reproduce this:

  % docker run --rm -it zshusers/zsh:5.8 zsh -fc \
      'zsh -fic "unsetopt monitor"; stty icanon'
  stty: 'standard input': Input/output error

This gives a different error but it looks like the same issue.
Replacing unsetopt with setopt gets rid of the error.

Roman.


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

* Re: Reverting the effect of 'setopt nomonitor' executed during shell startup
  2022-01-14 14:27 ` Roman Perepelitsa
@ 2022-01-14 17:26   ` Bart Schaefer
  0 siblings, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2022-01-14 17:26 UTC (permalink / raw)
  To: Roman Perepelitsa; +Cc: Andreas Hartmann, Zsh Users

On Fri, Jan 14, 2022 at 6:27 AM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
>   % >test.zsh <<\END
>   zsh -fic "unsetopt monitor"
>   stty icanon
>   END

More interesting is that if that is changed to

% >test.zsh <<\END
zsh -fic "unsetopt monitor"
setopt monitor
stty icanon
END

then stty is still stopped by TTOU but zsh is not and waits forever for it.

Move the "setopt monitor" into the -c argument (after the unsetopt)
and the whole script stops with TTOU again.  So it has something to do
with order of operations at startup.

I'm traveling today and can't look into it any further.


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

end of thread, other threads:[~2022-01-14 17:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 14:07 Reverting the effect of 'setopt nomonitor' executed during shell startup Andreas Hartmann
2022-01-14 14:27 ` Roman Perepelitsa
2022-01-14 17:26   ` Bart Schaefer

Code repositories for project(s) associated with this 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).