Opened 15 years ago

Last modified 7 years 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 by Jakub Jermář, 14 years ago

Milestone: 0.4.30.5.0

comment:2 by Martin Decky, 14 years ago

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 by Jakub Jermář, 14 years ago

Type: defectenhancement

comment:4 by Jakub Jermář, 13 years ago

Milestone: 0.5.00.5.1

comment:5 by Jakub Jermář, 10 years ago

Milestone: 0.5.10.7.1

comment:6 by Jakub Jermář, 7 years ago

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