bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undetected fatal errors from redirected print


From: Andrew J. Schorr
Subject: Re: Undetected fatal errors from redirected print
Date: Tue, 30 Nov 2021 15:26:56 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Tue, Nov 30, 2021 at 08:39:50AM -0700, arnold@skeeve.com wrote:
> > Miguel proposed adding the equivalent of
> >     efflush(stdout, "close_io", NULL);
> > at the top of that section. So that raises a few issues.
> 
> Please do not.
> 
> > So I'm not sure what to make of this. It seems there were some specific
> > policies established for how to handle stdout/stderr flush problems on 
> > exit. 
> 
> Yes. We report problems flushing them and trust the result from fflush()
> instead of trying to use fclose.
> 
> In short, let's leave that code as is.

I pushed it. I changed the 2nd arg to efflush in close_redir from
"close_redir" to "flush" because this looked weird:

bash-4.2$ strace -fo /tmp/trace.txt -P /tmp/answer.txt -e fault=write ./gawk 
'BEGIN {print "42" > "/tmp/answer.txt"}'
gawk: fatal: close_redir to "/tmp/answer.txt" failed: Function not implemented

This seems more understandable to me:

bash-4.2$ strace -fo /tmp/trace.txt -P /tmp/answer.txt -e fault=write ./gawk 
'BEGIN {print "42" > "/tmp/answer.txt"}'
gawk: fatal: flush to "/tmp/answer.txt" failed: Function not implemented

By the way, the logic in io.c:non_fatal_flush_std_file is somewhat similar to
builtin.c:wrerror. Maybe those should be somehow combined. Actually, the call
to w32_maybe_set_errno() appears in 6 places (main.c:usage, main.c:copyleft,
builtin.c:wrerror, io.c:non_fatal_flush_std_file, io.c:close_io). Maybe there
should be some attempt to unify this logic.

Regards,
Andy



reply via email to

[Prev in Thread] Current Thread [Next in Thread]