bug-coreutils
[Top][All Lists]
Advanced

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

bug#64540: [PATCH] od: exit out on failure to write to stdout


From: Pádraig Brady
Subject: bug#64540: [PATCH] od: exit out on failure to write to stdout
Date: Sat, 15 Jul 2023 22:08:38 +0100
User-agent: Mozilla Thunderbird

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

Attachment: 0001-tests-ensure-utilties-exit-promptly-upon-write-error.patch
Description: Text Data

Attachment: 0002-all-avoid-repeated-diagnostic-upon-write-error.patch
Description: Text Data

Attachment: 0003-od-promptly-diagnose-write-errors.patch
Description: Text Data

Attachment: 0004-uniq-promptly-diagnose-write-errors.patch
Description: Text Data

Attachment: 0005-cut-promptly-diagnose-write-errors.patch
Description: Text Data

Attachment: 0006-comm-promptly-diagnose-write-errors.patch
Description: Text Data

Attachment: 0007-join-promptly-diagnose-write-errors.patch
Description: Text Data


reply via email to

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