zsh-workers
 help / color / mirror / code / Atom feed
* [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY
@ 2021-07-12 10:02 Vincent Lefevre
  2021-07-12 12:13 ` Peter Stephenson
  2021-07-12 16:46 ` Mikael Magnusson
  0 siblings, 2 replies; 4+ messages in thread
From: Vincent Lefevre @ 2021-07-12 10:02 UTC (permalink / raw)
  To: zsh-workers

In my .zlogout, I have an "echo" command. However, if the terminal
is no longer there, the "echo" yields EIO errors and the remaining
of the .zlogout is not executed, e.g. with "echo foo" in .zlogout
and

  xterm -e strace -f -o str.out zsh -l

I get

17099 write(1, "foo\n", 4)              = -1 EIO (Input/output error)
17099 ioctl(2, TCGETS, 0x7ffc67792c80)  = -1 EIO (Input/output error)
17099 write(2, "/home/vlefevre/.zlogout:echo:7: "..., 64) = -1 EIO (Input/output error)
17099 ioctl(2, TCGETS, 0x7ffc67793030)  = -1 EIO (Input/output error)
17099 write(2, "/home/vlefevre/.zlogout:7: write"..., 59) = -1 EIO (Input/output error)
17099 rt_sigprocmask(SIG_BLOCK, [CHLD], [CHLD WINCH], 8) = 0
17099 rt_sigprocmask(SIG_UNBLOCK, [CHLD], [CHLD WINCH], 8) = 0
17099 ioctl(2, TCGETS, 0x7ffc67794790)  = -1 EIO (Input/output error)
17099 write(2, "/home/vlefevre/.zlogout:8: write"..., 39) = -1 EIO (Input/output error)
17099 close(11)                         = 0
17099 ioctl(10, TIOCSPGRP, [17096])     = -1 ENOTTY (Inappropriate ioctl for device)
17099 setpgid(0, 17096)                 = 0
17099 getpid()                          = 17099
17099 exit_group(1)                     = ?
17099 +++ exited with 1 +++

-- 
Vincent Lefèvre <vincent@vinc17.net> - 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)


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

* Re: [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY
  2021-07-12 10:02 [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY Vincent Lefevre
@ 2021-07-12 12:13 ` Peter Stephenson
  2021-07-14  8:04   ` Vincent Lefevre
  2021-07-12 16:46 ` Mikael Magnusson
  1 sibling, 1 reply; 4+ messages in thread
From: Peter Stephenson @ 2021-07-12 12:13 UTC (permalink / raw)
  To: Vincent Lefevre, zsh-workers

> On 12 July 2021 at 11:02 Vincent Lefevre <vincent@vinc17.net> wrote:
> In my .zlogout, I have an "echo" command. However, if the terminal
> is no longer there, the "echo" yields EIO errors and the remaining
> of the .zlogout is not executed, e.g. with "echo foo" in .zlogout
> and
> 
>   xterm -e strace -f -o str.out zsh -l

That's equivalent to this:

% cat source.zsh
exec 2>&-
echo Exiting2 >&2
echo Exiting
% ./zsh
% . ./source.zsh
<no output>
%

The inability to write to stderr to report the error writing to stderr
(I think, so not the original error on the *request* to write to stderr,
the fact it couldn't report the error) is treated as a hard error and causes
the sourced script to fail at that point.

Not sure what the right answer is.  We've also been looking at complaints that
zsh doesn't take errors with echo seriously enough...

pws


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

* Re: [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY
  2021-07-12 10:02 [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY Vincent Lefevre
  2021-07-12 12:13 ` Peter Stephenson
@ 2021-07-12 16:46 ` Mikael Magnusson
  1 sibling, 0 replies; 4+ messages in thread
From: Mikael Magnusson @ 2021-07-12 16:46 UTC (permalink / raw)
  To: zsh-workers

On 7/12/21, Vincent Lefevre <vincent@vinc17.net> wrote:
> In my .zlogout, I have an "echo" command. However, if the terminal
> is no longer there, the "echo" yields EIO errors and the remaining
> of the .zlogout is not executed, e.g. with "echo foo" in .zlogout
> and
>
>   xterm -e strace -f -o str.out zsh -l

If you're looking for a workaround in the meantime, I think this will
work (didn't test in .zlogout)

{ } always {
your actual code here
}

eg with Peter's example,
 exec 2>&-
 { } always {
 echo e2 >&2
 echo hi
 }
. ./source.zsh prints hi

-- 
Mikael Magnusson


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

* Re: [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY
  2021-07-12 12:13 ` Peter Stephenson
@ 2021-07-14  8:04   ` Vincent Lefevre
  0 siblings, 0 replies; 4+ messages in thread
From: Vincent Lefevre @ 2021-07-14  8:04 UTC (permalink / raw)
  To: zsh-workers

On 2021-07-12 13:13:20 +0100, Peter Stephenson wrote:
> That's equivalent to this:
> 
> % cat source.zsh
> exec 2>&-
> echo Exiting2 >&2
> echo Exiting
> % ./zsh
> % . ./source.zsh
> <no output>
> %
> 
> The inability to write to stderr to report the error writing to stderr
> (I think, so not the original error on the *request* to write to stderr,
> the fact it couldn't report the error) is treated as a hard error and causes
> the sourced script to fail at that point.
> 
> Not sure what the right answer is.  We've also been looking at complaints that
> zsh doesn't take errors with echo seriously enough...

I'd say that returning with a non-zero exit status is sufficient.
If the user wants the script to terminate after an error, he can
test the exit status or use "set -e". I don't see why the fact
that echo is a builtin should be treated differently.

-- 
Vincent Lefèvre <vincent@vinc17.net> - 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)


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

end of thread, other threads:[~2021-07-14  8:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-12 10:02 [BUG] zsh dies in case of EIO with echo in .zlogout / ENOTTY Vincent Lefevre
2021-07-12 12:13 ` Peter Stephenson
2021-07-14  8:04   ` Vincent Lefevre
2021-07-12 16:46 ` Mikael Magnusson

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