This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: glibc calls more write() than necessary


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]