Readablewiki

Read (system call)

Content sourced from Wikipedia, licensed under CC BY-SA 3.0.

Read is a system call you use to read data from a file. The file is identified by a file descriptor, usually obtained from open. Read copies up to count bytes from the file into a buffer you provide. It takes three arguments: the file descriptor, a pointer to the buffer, and the number of bytes to read. It returns the number of bytes actually read. A return value of 0 means end of file. The file offset moves forward by the number of bytes read. If fewer bytes are read than requested, that’s not necessarily an error; this can happen near end of file, when reading from a pipe or a terminal, or if a signal interrupts the call. If an error occurs, read returns -1 and errno is set. It is unspecified whether the file position changes if an error occurs.


This page was last edited on 2 February 2026, at 23:08 (CET).