Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

readv - read array from file

&pagelevel(4)&pagelevel

Syntax

#include <sys/uio.h>

ssize_t readv(int fildes, const struct iovec *iov, int iovcnt); 

Description

See read() .

readv() behaves like read() but reads the input data from the file belonging to fildes into the iovcnt buffers which are specified as elements of the iov field:
iov[0], iov[1], ..., iov[iovcnt-1].
0 must be < iovcnt <= {IOV_MAX}

The iovec structure contains the following elements:

addr_t      iov_base;

size_t      iov_len;

Each iovec entry specifies the basic address and length of a storage area (buffer) in which data is to be put. readv() always fills a buffer completely before going on to the next one.

If successful, readv() returns the number of bytes that were actually read and written to the buffer. If the end of file is reached, 0 is returned.

Return val.

integer >0

if successful. The number is the number of bytes that were actually read.


0

if the end of file (EOF) was reached during reading.


-1

if an error occurs. errno is set to indicate the error. The contents of the buffer are undefined.

Errors

readv() will fail if:

 

EAGAIN

The O_NONBLOCK flag is set for the file descriptor and the process would be suspended by the read operation.

 

Extension

 

EAGAIN

The currently available amount of system memory for "raw" I/O is insufficient
or there is no data in a terminal device file waiting to be read, and O_NONBLOCK is set
or there is no message in a stream waiting to be read, and O_NONBLOCK is set. (End)

 

EBADF

fildes is not a valid file descriptor open for reading.

 

EBADMSG

The file is a STREAM file in control-normal mode, but the message waiting to be read contains a control section.

 

EFAULT

iov points outside the allocated address space of the process.


EINTR

The read operation was terminated due to the receipt of a signal, and no data was transferred.


EINVAL

An attempt was made to read from a stream linked with a multiplexer
or the sum of the iov-len values in the iov field caused a ssize_t overflow
or iovcnt ≤ 0 or iovcnt > 16.


EIO

A physical I/O error has occurred
or the process is a member of a background process group attempting to read from its controlling terminal. The process is ignoring or blocking the  SIGTTIN signal

or the process group is orphaned.


EISDIR

fildes describes a directory that cannot be read with readv(). readdir() should be used instead.


ENXIO

A request was made for a non-existent device
or the request exceeded the capabilities of the device.


ENOLINK

fildes is located on a remote computer to which the link is no longer active.


A readv() from a STREAMS file will also fail if an error message is received at the stream head. In this case, errno is set to the value that is returned in the error message. If a hangup occurs in the stream currently being read, readv() continues running normally until the read queue of the stream head is empty. Thereafter 0 is returned.

Syntax

fcntl(), ioctl(), lseek(), open(), pipe(), stropts.h, sys/uio.h, unistd.h.