This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: glibc calls more write() than necessary
- From: Matthieu Lemerre <racin at free dot fr>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Sun, 21 Jan 2007 22:03:15 +0100
- Subject: Re: glibc calls more write() than necessary
- References: <87odos5eih.fsf@free.fr> <200701211547.52736.vapier@gentoo.org>
Mike Frysinger <vapier@gentoo.org> writes:
> On Sunday 21 January 2007 15:08, Matthieu Lemerre wrote:
>> int
>> main (int argc, char **argv)
>> {
>> printf ("hello\nworld\ne");
>> printf ("hello\n\%s\n","char");
>> }
>>
>> yields (with strace)
>>
>> write(1, "hello\n", 6hello
>> ) = 6
>> write(1, "world\n", 6world
>> ) = 6
>> write(1, "ehello\n", 7ehello
>> ) = 7
>> write(1, "char\n", 5char
>
> this is correct and standards conforming ... please read the setbuf(3) manpage
> -mike
Maybe I wasn't clear enough... My concern is the following one: when a
stream is line buffered, I think that the flush need to be done only
at the LAST '\n', not at each one of them. That way, you flush less,
you syscall less, and the program run faster.
I don't see any reason for not doing what I propose, but there might
be: please tell me if so.
Matthieu Lemerre