01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

READ (2) READ (2)<br />

NAME<br />

read - read from file<br />

SYNOPSIS<br />

int read (fildes, bur, nbyte)<br />

int fildes;<br />

char *bur;<br />

unsigned_ nbyte;<br />

DESCRIPTION<br />

Fildes is a file descriptor obtained from a ere at, open, dup, fcntl ,<br />

or pipe system call.<br />

Read attempts to read nbyte bytes from the file associated with<br />

fildes into the buffer pointed to by buf.<br />

On devices capable of seeking, the read starts at a position in the<br />

file given by the file pointer associated with fildes . Upon return<br />

from read, the file pointer is incremented by the number of bytes<br />

actually read.<br />

Devices that are incapable of seeking always read from the current<br />

position. The value of a file pointer associated with such a file is<br />

undefined.<br />

Upon successful completion, read returns the number of bytes<br />

actually read and placed in the buffer; this number may be less<br />

than nbyte if the file is associated with a communication line (see<br />

ioctl(2) and termio(7)), or if the number of bytes left in the file is<br />

less than nbyte bytes. A value of 0 is returned when an end-of-file<br />

has been reached.<br />

When attempting to read from an empty pipe (or FIFO):<br />

If O_NDELAY is set, the read will return a 0.<br />

If O_NDELA Y is clear, the read will block until data is<br />

written to the file or the file is no longer open for writing.<br />

When attempting to read a file associated with a tty that has no<br />

data currently available:<br />

If O_NDELAY is set, the read will return a 0.<br />

If O_NDELAY is clear, the read will block until data<br />

becomes available.<br />

Read will fail if one or more of the following are true:<br />

Fildes is not a valid file descriptor open for reading.<br />

!EBADFj<br />

Buf points outside the allocated address space. !EF AUL Tj<br />

RETURN VALUE<br />

Upon successful completion a non-negative integer is returned<br />

indicating the number of bytes actually read. Otherwise, a - 1 is<br />

returned and errno is set to indicate the error.<br />

SEE ALSO<br />

creat(2), dup(2), fcntl(2), ioctl(2), open(2), pipe(2), termio(7), window(7).<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!