fcntl(3)

DESCRIPTION

Manipulates descriptor and open-file-description flags. F_DUPFD and F_DUPFD_CLOEXEC allocate atomically from a requested minimum; F_GETFD and F_SETFD access FD_CLOEXEC; F_GETFL and F_SETFL access O_APPEND and O_NONBLOCK.

SYNOPSIS

#include <fcntl.h>

int fcntl(int fd, int command, ...);

RETURN VALUE

  • Returns a new descriptor, a flag word, or zero
  • otherwise -1 and sets errno.

ERRORS

  • -EBADF
    • Fd does not refer to an open descriptor.
  • -EINVAL
    • The command, minimum descriptor, or flag word is unsupported.
  • -EMFILE
    • No descriptor is available at or above the requested minimum.

NOTES

Descriptor flags are not copied by ordinary duplication. Status flags are shared by aliases of the same open file description; the native operation does not poll or bypass the AIO descriptor layer.