getchar_unlocked

Returns a character from the stdin stream.

Library:LibC
Classification:POSIX
Service:File and Directory I/O
Multithread Use:Unsafe

Syntax

  #include <stdio.h> 
   
  int getchar_unlocked ( void );
  

Return Values

If successful, returns the next byte from the input stream pointed to by stdin. If the stream is at end-of-file, getchar_unlocked sets the EOF indicator and returns EOF. If a read error occurs, getchar_unlocked sets the error indicator, returns EOF, and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not valid for reading.

5

ENOMEM

Insufficient storage space is available.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the read operation.

25

ENXIO

A request was made of a nonexistent device, or the request was outside the capabilities of the device.

28

EIO

The process is orphaned and cannot write to the file.

63

EINTR

A signal interrupted the read operation.

81

EOVERFLOW

The file is a regular file and an attempt was made to read at or beyond the offset maximum associated with the corresponding stream.

Remarks

The getchar_unlocked function is a non-thread safe version of the getchar function. It should be used in a multi-threaded program only if the invoking thread has locked stdin.

See Also