int fd_copy(int to,int from);
int fd_move(int to,int from);
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
fd_copy and fd_move return 0 on success, and -1 on error.
Man(1) output converted with