Syntax | #include <unistd.h> ssize_t read(int fildes, void *buf, size_t nbyte); | |
Description |
the buffer pointed to by buf. fildes is a file descriptor returned by a call to If nbyte is 0, On files that support seeking (for example, a regular file), Files that do not support seeking, for example, terminals, always read from the current position. The value of a file offset associated with such a file is undefined. No data transfer will occur past the current end-of-file. If the starting position is at or after the end-of-file, 0 will be returned. The following occurs when attempting to read from an empty pipe or FIFO:
The following occurs when attempting to read a file (other than a pipe or FIFO) that supports non-blocking reads and has no data currently available:
The Upon successful completion, where nbyte is greater than 0, If a If a If threads are used, then the function affects the process or a thread in the following manner: When an attempt is made to read from an empty pipe or FIFO, the following occurs: If a process has opened the pipe for writing and O_NONBLOCK is not set, | |
Return val. | Number of bytes actually read | |
upon successful completion. | ||
| 0 | at end-of-file. |
| -1 | if an error occurs. The contents of the buffer to which buf points are undefined. |
Errors |
| |
|
| The |
| Extension | |
|
| The currently available amount of system memory for "raw" I/O is insufficient |
|
| fildes is not a valid file descriptor open for reading. |
|
| buf points outside the allocated address space of the process. |
| The read operation was terminated due to the receipt of a signal, and no data was transferred. | |
| An attempt was made to read from a stream linked with a multiplexer. | |
| A physical I/O error has occurred | |
| A request was made for a non-existent device or the request exceeded the capabilities of the device. | |
Notes | The number of bytes actually read may be less than the value specified in nbytes if the end of the line is reached first (only for text files) and at end-of-file or the occurrence of an error. The BS2000 The following applies in the case of text files with SAM access mode and variable record length for which a maximum record length is also specified: When the specification O_NOSPLIT was entered for The program environment determines whether | |
See also |
|