Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: precmd: write error: interrupted



On Apr 25,  6:47pm, Yuri D'Elia wrote:
} 
} I still have the error, as I didn't find any way to silence it (braces 
} around print do not work?!).

That's curious, but try using parentheses to force a fork and redirect
the stderr of the subshell.

} I have no idea which write is actually failing in that function (I 
} suppose it's some "fputs" in bin_print).

strace should be able to show you what bytes are being written, which
would narrow it down.

} :(. I really wished I had dtrace here...

On every host where I have dtrace, I wish I had strace.
 
} What's happening is that the terminal is being resized immediately after 
} starting, and a SIGWINCH is emitted while the actual "precmd" write is 
} being done on stdout. The call is not restarted and the write fails.

Yes, the zsh signal handler setup explicitly prevents system call restart
whenever possible, so that (among other reasons) behavior from traps is
consistent across operating systems.

} 1) SIGWINCH should either be masked or allow write to restart.

This requires some thought about the appropriate layer to handle this.
bin_print does already do some signal queuing when writing to internal
data structures (print -z, print -s), but that's deliberately isolated
to bin_print, whereas all sorts of other things might write to the
terminal -- including other error messages! -- so patching bin_print is
not covering all the bases.

On the other hand we probably don't want to build a wrapper around the
entire stdio library just to differentiate terminal writes.

} 2) Why "precmd() { { print "HELLO" } >&- 2>&-; } doesn't suppress the 
} error in this case?

It's not the same error.  Try 2>/dev/null instead of 2>&- ... with the
stderr closed, you're actually getting a second error from outside the
braces, about not being able to write the first error from inside!

torch% print -u99 "Hello"    
print: bad file number: -1
torch% { print -u99 "Hello" } 2>&-
zsh: write error
torch% { print -u99 "Hello" } 2>/dev/null
torch% 



Messages sorted by: Reverse Date, Date, Thread, Author