write(3)

DESCRIPTION

Writes up to length bytes from buffer at the descriptor's current position. Pipe writes can be short when the 4096-byte pipe buffer has limited space.

SYNOPSIS

#include <unistd.h>

long write(int fd, const void *buffer, unsigned long length);

RETURN VALUE

  • Returns the byte count, possibly less than length, or -1 and sets errno.

ERRORS

  • -EBADF
    • Fd does not refer to an open descriptor.
  • -EFAULT
    • Buffer is not accessible for length bytes.
  • -EPIPE
    • The pipe has no readers.
  • -EIO
    • The underlying file or device reports an I/O failure.

NOTES

The synchronous libc call is implemented as one OP_WRITE submission on the process AIO ring. O_APPEND is resolved by the kernel.