Manpage logo

fd - duplicate, move or close a file descriptor

NAME  SYNTAX  DESCRIPTION  RETURN CODES  SEE ALSO 

NAME

fd − duplicate, move or close a file descriptor

SYNTAX

#include "fd.h"

int fd_copy(int to,int from);
int fd_move(int to,int from);
int fd_coe(int fd);

DESCRIPTION

fd_copy copies descriptor from to descriptor to. If to was already open, fd_copy closes it. fd_copy always leaves from intact; if to and from are the same number, fd_copy does nothing. fd_copy does not guarantee that to will remain open, if it was open, in case of error.

fd_move moves descriptor from to descriptor to. If to was already open, fd_move closes it. If the move is successful, fd_move closes from. Exception: if to and from are the same number, fd_move does nothing.

fd_coe closes fd.

RETURN CODES

fd_copy, fd_move, and fd_coe return 0 on success, and -1 on error.

SEE ALSO

dup(2), fcntl(2)


Updated 2026-06-01 - jenkler.se | uex.se