GNU bug report logs - #64540
[PATCH] od: exit out on failure to write to stdout

Previous Next

Package: coreutils;

Reported by: Josef Bacik <josef <at> toxicpanda.com>

Date: Sun, 9 Jul 2023 09:09:02 UTC

Severity: normal

Tags: patch

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 64540 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>, Josef Bacik <josef <at> toxicpanda.com>,
 64540 <at> debbugs.gnu.org
Subject: Re: bug#64540: [PATCH] od: exit out on failure to write to stdout
Date: Sat, 15 Jul 2023 22:08:38 +0100
[Message part 1 (text/plain, inline)]
On 09/07/2023 23:54, Pádraig Brady wrote:
> On 09/07/2023 20:11, Paul Eggert wrote:
>> On 2023-07-09 07:11, Pádraig Brady wrote:
>>
>>> Note the patch looks wrong as it would close the input always.
>>> We can fix that up easily enough anyway.
>>
>> If it's easy and doesn't hurt performance in the usual case, that's of
>> course fine.
>>
>>
>>> For my reference a short list of utils to check (that might inf loop) are:
>>>      cat comm cp cut dd dirname expand factor fmt fold head join ls nl numfmt
>>>      od paste pr printf ptx readlink realpath seq shuf sort stat tac tail
>>>      tee tr tsort unexpand uniq wc yes
>>
>> There's no point to complicating programs that have bounded input for
>> other reasons, as they'll report errors soon enough for those other
>> reasons. The main problem comes from programs like 'cat' and 'od' that
>> can read from "infinite" input like /dev/urandom and can write indefinitely.
>>
>> So I think we needn't worry about dirname, ptx, readlink, realpath,
>> sort, stat, tac, tsort, wc. For example, we needn't worry about 'sort'
>> because it needs to read all its input before outputting anything, and
>> it cannot read all of /dev/urandom. As long as these programs eventually
>> check for write errors, which I expect they all do, that should be good
>> enough.
>>
>> Even for programs like 'od' there is no need to check every output
>> function; just check occasionally, when it's convenient.
> 
> Yes completely agreed.
> The shortlist above is for my reference for commands to review,
> not for commands to adjust.

The attached patch-set addresses two classes of issue:
1. Doubled error messages upon write errors
2. Continued processing upon write errors  (the orig problem reported).

For class 1, we include fixes for:
  expand, factor, paste, shuf, tr, unexpand

For class 2, we include fixes for:
  od, uniq, cut, comm, join
For class 2, we do _not_ include fixes for these utils
which are more awkward / less important in this context:
  fmt, fold, nl, numfmt, pr

I'll update NEWS with this info before pushing.

cheers,
Pádraig
[0001-tests-ensure-utilties-exit-promptly-upon-write-error.patch (text/x-patch, attachment)]
[0002-all-avoid-repeated-diagnostic-upon-write-error.patch (text/x-patch, attachment)]
[0003-od-promptly-diagnose-write-errors.patch (text/x-patch, attachment)]
[0004-uniq-promptly-diagnose-write-errors.patch (text/x-patch, attachment)]
[0005-cut-promptly-diagnose-write-errors.patch (text/x-patch, attachment)]
[0006-comm-promptly-diagnose-write-errors.patch (text/x-patch, attachment)]
[0007-join-promptly-diagnose-write-errors.patch (text/x-patch, attachment)]

This bug report was last modified 1 year and 304 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.