GNU bug report logs - #8961
stdbuf has no effect on some programs

Previous Next

Package: coreutils;

Reported by: Bruno Haible <bruno <at> clisp.org>

Date: Wed, 29 Jun 2011 21:00:03 UTC

Severity: normal

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

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Pádraig Brady <P <at> draigBrady.com>
To: Paolo Bonzini <bonzini <at> gnu.org>
Cc: 8961 <at> debbugs.gnu.org, Bruno Haible <bruno <at> clisp.org>
Subject: bug#8961: stdbuf has no effect on some programs
Date: Mon, 04 Jul 2011 10:08:06 +0100
[Message part 1 (text/plain, inline)]
On 03/07/11 23:38, Pádraig Brady wrote:
> On 03/07/11 18:50, Bruno Haible wrote:
>> I wrote:
>>> Likewise for "-o0".
>>
>> Oops, please forget the statement about -o0. With the modified GNU libiconv
>> 'iconv' program, -o0 does make a difference:
>>   $ (echo -n abc; sleep 1; echo def) | iconv
>> vs.
>>   $ (echo -n abc; sleep 1; echo def) | stdbuf -o0 iconv
>> In the first case, output is line buffered. In the second case, "abc"
>> occurs immediately.
>>
>> Bruno
> 
> Also "-i0" is useful if a command doesn't consume all of input,
> and needs a subsequent command to process the rest, like:
> 
> producer | (stdbuf -i0 cmd1; cmd2)
> 
> I'll expand the info to make this function apparent.

Hmm, this especially useful with sed, where one
can [Qq]uit early depending on the input.

But I notice that sed no longer supports `setbuf -i0`.
This is because of 3a8e165a which discards the
original stdin and instead fdopens() a new one
to support reading in binary mode on windos.
http://git.sv.gnu.org/gitweb/?p=sed.git;a=commit;h=3a8e165a

Note in sed 4.2.2 the -u option was enhanced to
support this internally (the documentation had already
said that -u did this), so only sed 4.2 and 4.2.1
have no way to control this.

In any case there is no point I think opening
a new stream for stdin on non windos platforms
as it adds a bit of overhead, and precludes the
use of setbuf -i...

So how about the attached patch?

cheers,
Pádraig.
[sed-i0.diff (text/x-patch, attachment)]

This bug report was last modified 13 years and 358 days ago.

Previous Next


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