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

Re: precmd: write error: interrupted

On 04/25/2013 08:16 PM, Bart Schaefer wrote:
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.

This, of course, works. But I wouldn't want to fork here just to ignore the error message.

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

not really, apart from the "write error:" which I already knew. But there are only two possible points in bin_print, and I'm using the "unformatted" case.

} 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!

You are right. I pasted one of my numerous trials in an attempt to exploit the EBADF errno.

But anyway:

precmd() { { print x } 2>/dev/null }

still doesn't suppress the error.

By looking at bin_print, zwarnnam is used.

In the "normal output case" (Src/builtin.c:6310) there's an explicit test for >&- redirection of stdout, and that's it. I see nothing in zwarnnam except for the noerrs global that would allow error redirection to work in lists.

Maybe there's a builtin to force "noerrs" instead?

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