dup2(3)

DESCRIPTION

Makes new_fd refer to the same open file description as old_fd. An existing target is replaced; equal numbers are left unchanged.

SYNOPSIS

#include <unistd.h>

int dup2(int old_fd, int new_fd);

RETURN VALUE

  • Returns new_fd, or -1 and sets errno.

ERRORS

  • -EBADF
    • Old_fd is invalid or new_fd is outside the process descriptor table.

NOTES

The requested descriptor number is installed directly.