|This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.|
Write bytes to a file
#include <sys/uio.h> ssize_t writev( int fildes, const iov_t* iov, int iovcnt );
- The file descriptor for the file you want to write in.
- An array of iov_t objects that contain the data that you want to write.
- The number of elements in the array.
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The writev() function performs the same action as write(), but gathers the output data from the iovcnt buffers specified by the members of the iov array: iov, iov, ..., iov[iovcnt-1].
For writev(), the iov_t structure contains the following members:
- Base address of a memory area from which data should be written.
- The length of the memory area.
The writev() function always writes a complete area before proceeding to the next.
The maximum number of entries in the iov array is UIO_MAXIOV.
|Note that writev() ignores advisory locks that may have been set by the fcntl() function.|
If writev() is interrupted by a signal before it has written any data, it returns a value of -1, and errno is set to EINTR. However, if writev() is interrupted by a signal after it has successfully written some data, it will return the number of bytes written.
For more details, see the write() function.
The number of bytes written, or -1 if an error occurs (errno is set).
- The O_NONBLOCK flag is set for the file descriptor, and the process would be delayed in the write operation.
- The file descriptor, fildes, isn't a valid file descriptor open for writing.
- The file is a regular file, where nbytes is greater than 0, and the starting position is greater than or equal to the offset maximum associated with the file.
- The write operation was interrupted by a signal, and either no data was transferred, or the resource manager responsible for that file doesn't report partial transfers.
- The iovcnt argument is less than or equal to 0, or greater than UIO_MAXIOV.
- A physical I/O error occurred (for example, a bad block on a disk). The precise meaning is device-dependent.
- There is no free space remaining on the device containing the file.
- The write() function isn't implemented for the filesystem specified by filedes.
- An attempt was made to write to a pipe (or FIFO) that isn't open for reading by any process. A SIGPIPE signal is also sent to the process.