read(2) System Calls Manual read(2) read - LIBRARY Standard C library (libc, -lc) #include ssize_t read(int fd, void buf[.count], size_t count); read() count fd , buf. , , , . , read() . count 0, read() , . , read() , read() count 0 0 . POSIX.1, count SSIZE_MAX, ; Linux. ( ), . , , : , - , ( - , , ), read() . . . On error, -1 is returned, and errno is set to indicate the error. In this case, it is left unspecified whether the file position (if any) changes. EAGAIN fd , / (O_NONBLOCK), . . open(2) O_NONBLOCK. EAGAIN EWOULDBLOCK fd (O_NONBLOCK), . POSIX.1-2001 , , . EBADF fd . EFAULT buf . EINTR ; . signal(7). EINVAL fd , ; O_DIRECT, buf, count . EINVAL fd timerfd_create(2), read() ; . timerfd_create(2). EIO /. , , , , SIGTTIN, . , - . EIO , . fcntl(2). EISDIR fd . , fd, . POSIX.1-2008. SVr4, 4.3BSD, POSIX.1-2001. Linux read() ( ) 0x7ffff000 (2 147 479 552) , , ( 32-, 64- ). NFS , . , ( ) NFS st_atime ( ), , , st_atime, . UNIX , . POSIX.1-2008/SUSv4 XSI 2.9.7 ("Thread Interactions with Regular File Operations"): , , POSIX.1-2008: Among the APIs subsequently listed are read() and readv(2). And among the effects that should be atomic across threads (and processes) are updates of the file offset. However, before Linux 3.14, this was not the case: if two processes that share an open file description (see open(2)) perform a read() (or readv(2)) at the same time, then the I/O operations were not atomic with respect updating the file offset, with the result that the reads in the two processes might (incorrectly) overlap in the blocks of data that they obtained. This problem was fixed in Linux 3.14. . close(2), fcntl(2), ioctl(2), lseek(2), open(2), pread(2), readdir(2), readlink(2), readv(2), select(2), write(2), fread(3) aereiae , Azamat Hackimov , Dmitriy S. Seregin , Katrin Kutepova , Lockal , Yuri Kozlov , ; GNU 3 , . . , , . Linux man-pages 6.06 31 2023 . read(2)