Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Non-canonical mode input processing

&pagelevel(5)&pagelevel

This type of input processing is only supported by character-oriented terminals, not by block terminals.

In non-canonical mode input processing, input bytes are not assembled into lines, and erase and kill processing does not occur. The values of the MIN and TIME elements of the c_cc array are used to determine how the process is to receive the bytes. The O_NONBLOCK flag (see also open() or fcntl()) has precedence over the specifications in the c_cc array. Consequently, if O_NONBLOCK is set, read() will return immediately, regardless of the MIN and TIME values. Furthermore, if no data is present, read() can return either 0 or -1 and set errno to EAGAIN in the latter case.

MIN represents the minimum number of bytes (maximum 255) that should be received (i.e. returned to the user) when the read() function successfully returns. TIME is a timer of 0.1 second granularity that is used to time-out bursty and short term data transmissions. If MIN is greater than {MAX_INPUT}, the response to the request is not defined. The four possible combinations for MIN and TIME and their interactions are described below:

Case 1: MIN > 0, TIME > 0

In this case TIME serves as an inter-byte timer and is activated after the first byte is received. Since it is an inter-byte timer, TIME is reset for each byte and started as soon as one byte is received. If MIN bytes are received before the inter-byte timer expires, the read operation is satisfied. If the timer expires before MIN bytes are received, the characters received to that point are returned to the user. Note that if TIME expires, at least one byte is returned, since the timer is not enabled unless a byte is received. In this case (MIN > 0, TIME > 0) the read blocks until either the MIN and TIME mechanisms are activated by the receipt of the first byte, or a signal is received.

Case 2: MIN > 0, TIME = 0

Since the value of TIME is zero, the timer plays no role, and only MIN is significant. In this case, the read operation blocks until MIN bytes are received or a signal arrives. A program that uses this case to read records from the terminal may block for any length of time in the read operation (even indefinitely).

Case 3: MIN = 0, TIME > 0

Since MIN = 0, TIME no longer represents an inter-byte timer in this case but serves as a read timer (for the entire read operation) that is activated as soon as the call to read() is processed (default action). In this case, a read operation is satisfied as soon as a single byte is received or the read timer TIME expires. If no byte is received within TIME * 0.1 seconds after read() is called, the read() function returns a value of zero, having read no data.

Case 4: MIN = 0, TIME = 0

In this case, either the number of bytes to be read or the number of bytes currently available (if there are not enough bytes) is returned without waiting for more bytes to be input. If no input characters are available, the read() function returns a value of zero, having read no data.