setvbuf using IOFBF max buffer size
tomas@tuxteam.de
tomas@tuxteam.de
Sun May 4 05:42:50 GMT 2025
On Sat, May 03, 2025 at 11:11:48PM -0400, violette via Libc-help wrote:
> Hello mailing list people!
Hi, Violette
> I am trying to print a whole screen worth of text using `printf`.
> I have set my terminal as full line buffer using
> `setvbuf(stdout, buf, _IOFBF, sizeof(buf)` (with a buffer size of
> `UINT_16_MAX`). I am using glibc 2.41 and gcc.
>
> Apparently, it buffers and has to print a few times times before
> `fflush` is even called. It also seems that it writes to screen
> the same number of time as when the buffer size is set to `BUFSIZ`.
If I'm reading the man page correctly, this is expected: you set
the mode to `_IOFBUF', i.e. "fully buffered": therefore, the buffer
will only get flushed once it gets full.
This matches the behaviourI think you are describing above: you
have to call printf a couple of times and then, all the stuff
collected in the buffer is sent out.
Or, perhaps I'm misunderstanding you? Could you explain a bit more
what behaviour you expect?
Cheers
--
tomás
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/libc-help/attachments/20250504/b73c129b/attachment.sig>
More information about the Libc-help
mailing list