write - write to a file descriptor in operation

Outline

#include <unistd.h>

ssize_t write(int fd, const void *buf, size_t count);

description

write to a file descriptor fd written from a file referenced in buf buffer, starting count data bytes. POSIX predetermined, when a write () after reuse Read () , it should be updated to read after the data. However, please note that not all file systems are POSIX-compliant.

return value

It returns the number of bytes successfully written (if zero indicates that no data is written). -1 if an error, and set errno to the corresponding value. If the count is zero, no effect on normal file, but for special files will have unpredictable consequences.

error code

EBADF
fd is not a valid file descriptor or is not open for writing.
chosen
fd pointed object is not to write.
EFAULT
buf is not accessible to the user address space.
EPIPE
fd is connected to a pipe or socket closed end of this time the direction of the read writing process received. SIGPIPE signal; if this signal is caught, blocked or ignored, an error will be returned EPIPE.
EAGAIN
Blocking read, but using O_NONBLOCK specified input and output non-blocking.
ENTRY
Before writing the data signal call was interrupted.
ENOSPC
fd device where the file pointed to no available space.
EIO
Underlying input output error occurs when a node editing.

Other errors may have occurred, depending on fd objects connected.

Compatible

. SVr4, SVID, POSIX, X / OPEN, 4.3BSD SVr4 document adds the following error codes: EDEADLK, EFBIG, ENOLCK, ENOLNK, ENOSR, ENXIO, EPIPE, or ERANGE SVr4 may occur when writing the part of the data for the interruption. and return EINTR. 

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11102384.html