[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: |
Mon, 29 Nov 2021 17:33:35 -0500 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Sat, Nov 27, 2021 at 10:33:20AM -0500, Andrew J. Schorr wrote:
> On Sat, Nov 27, 2021 at 04:08:28AM -0500, Miguel Pineiro Jr. wrote:
> > Hi, Andy
> >
> > On Fri, Nov 26, 2021, at 11:28 AM, Andrew J. Schorr wrote:
> > > Interesting. Do we actually need the goto in efwrite, or can we just
> > > skip the fwrite call if count is 0? That way, we can avoid the ugliness
> > > of testing the first character of `from'. See the attached patch.
> >
> > Testing the first character of from, I agree, is ugly. Though effective,
> > it's cryptic and arbitrary.
> >
> > The goto isn't necessary, but I think it actually makes the code and the
> > intent very easy to follow: If this condition is true, jump to the flush.
> >
> > I see two issues with your patch:
> >
> > 1. If I understand your intent, efwrite should flush when count is 0, but
> > it doesn't. The flushing conditional expression needs OR-ing with "count ==
> > 0".
>
> Well, but the call to efwrite has the has the final argument `flush' set to
> true, so the the "if" condition is going to succeed when rp is non-NULL.
> The stdout case is a bit tricker, since it could fail if it's not a tty.
> So you've got a valid point there if we want to use efwrite to flush stdout
> from close_io. What about stderr?
On 2nd thought, I'd argue that efwrite should actually be factored into
three different functions: efwrite, efflush, and wrerror, as in the
attached patch. That just leaves the question of whether efflush should
be called in close_io for stdout and possibly stderr, which already have
some special fflush error handling.
Regards,
Andy
P.S. I'm getting a "make check" ordering error for the iolint test in the
master branch, but I imagine that's unrelated:
--- iolint.ok 2021-11-21 18:16:26.442106000 -0500
+++ _iolint 2021-11-29 17:30:29.657143000 -0500
@@ -20,9 +20,9 @@
0
0
gawk: iolint.awk:53: warning: `cat' used for output file and output pipe
-0
hello
0
+0
gawk: iolint.awk:67: warning: `eval $CMD_TO_RUN' used for input pipe and output
pipe
0
0
efflush.patch
Description: Text document
- Re: Undetected fatal errors from redirected print, (continued)
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/23
- Re: Undetected fatal errors from redirected print, Miguel Pineiro Jr., 2021/11/23
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/24
- Re: Undetected fatal errors from redirected print, arnold, 2021/11/25
- Re: Undetected fatal errors from redirected print, Miguel Pineiro Jr., 2021/11/26
- Re: Undetected fatal errors from redirected print, arnold, 2021/11/26
- Re: Undetected fatal errors from redirected print, Miguel Pineiro Jr., 2021/11/26
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/26
- Re: Undetected fatal errors from redirected print, Miguel Pineiro Jr., 2021/11/27
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/27
- Re: Undetected fatal errors from redirected print,
Andrew J. Schorr <=
- Re: Undetected fatal errors from redirected print, arnold, 2021/11/30
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/30
- Re: Undetected fatal errors from redirected print, arnold, 2021/11/30
- Re: Undetected fatal errors from redirected print, Andrew J. Schorr, 2021/11/30