Follow us on Google+ Follow us on Facebook Follow us on Twitter

Opened 8 years ago

Last modified 5 weeks ago

#202 new enhancement

fgetc() should be smarter about buffer flushing

Reported by: Jiri Svoboda Owned by:
Priority: major Milestone:
Component: helenos/unspecified Version: mainline
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

Currently fgetc() tries to flush stdout and stderr every time it's called. This is because if we are reading from stdin, the standard behavior is to actually display everything that was sent to stdout before.

Right now fgetc() is probably too conservative. Question is how smart it needs to be when deciding whether to flush (so that it's not overly progressive). Is it enough to check whether stream == stdin or do we need to check whether the underlying file descriptor is a console? (We probably should).

This problem contributes to slow reading of stdin. See also #200 and #201.

Change History (6)

comment:1 Changed 7 years ago by Jakub Jermář

Milestone: 0.4.30.5.0

comment:2 Changed 7 years ago by Martin Decky

The Linux manual page states about output streams flushing rules (for reference):

"Output streams that refer to terminal devices are always line buffered by default; pending output to such streams is written automatically whenever an input stream that refers to a terminal device is read."

This means that:

(a) Every output stream which is associated with a terminal should be flushed when you want to read the stream, this does not cover only stdin/out/err.

(b) There's no such requirement for streams which are not associated with a terminal, even if they are called stdin/out/err.

And as a side note: © stderr should be unbuffered by default.

comment:3 Changed 7 years ago by Jakub Jermář

Type: defectenhancement

comment:4 Changed 6 years ago by Jakub Jermář

Milestone: 0.5.00.5.1

comment:5 Changed 3 years ago by Jakub Jermář

Milestone: 0.5.10.7.1

comment:6 Changed 5 weeks ago by Jakub Jermář

Milestone: 0.7.1
Note: See TracTickets for help on using tickets.