glibc calls more write() than necessary
Matthieu Lemerre
racin@free.fr
Sun Jan 21 21:01:00 GMT 2007
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
More information about the Libc-alpha
mailing list