read.2 (2010 09)

r
read(2) read(2)
The readv() function may fail if:
[EINVAL] The
iovcnt argument was less than or equal to 0, or greater than
{IOV_MAX}.
The
pread() function will fail and the file pointer remains unchanged if:
[EINVAL] The offset argument is invalid. The value is negative.
[EOVERFLOW] The file is a regular file and an attempt was made to read at or beyond the offset
maximum associated with the file.
[ESPIPE] fildes is associated with a pipe or FIFO.
EXAMPLES
Assuming a process opened a file for reading, the following call to read (2) reads
BUFSIZ bytes from the
file into the buffer pointed to by mybuf:
#include <stdio.h> /* include this for BUFSIZ definition */
char mybuf[BUFSIZ];
int nbytes, fildes;
nbytes = read (fildes, mybuf, BUFSIZ);
WARNINGS
Record locking might not be enforced by the system, depending on the setting of the file’s mode bits (see
lockf (2)).
Character-special devices, and raw disks in particular, apply constraints on how
read() can be used.
See the specific Section (7) entries for details on particular devices.
In general, avoid using
read() to get the contents of a directory; use the readdir() library routine
(see directory (3C)).
DEPENDENCIES
NFS
When obtaining the contents of a directory on an NFS file system, the
readdir() library routine must
be used (see directory (3C)). read() returns with an error if used to read a directory using NFS.
AUTHOR
read() was developed by HP, AT&T, and the University of California, Berkeley.
SEE ALSO
fcntl(2), ioctl(2), lseek(2), open(2), pipe(2), creat(2), dup(2), lockf(2), select(2), ustat(2), directory(3C),
tty(7), <stropts.h>, <sys/uio.h>, <unistd.h>, XBD Specification, Chapter 9, General Terminal Interface.
STANDARDS CONFORMANCE
read(): AES, SVID2, SVID3, XPG2, XPG3, XPG4, FIPS 151-2, POSIX.1, POSIX.4
4 Hewlett-Packard Company 4 HP-UX 11i Version 3: September 2010