fd_move.c (291B)
1 /* ISC license. */ 2 3 #include <unistd.h> 4 #include <errno.h> 5 #include <skalibs/djbunix.h> 6 7 int fd_move (int to, int from) 8 { 9 int r ; 10 if (to == from) return 0 ; 11 do 12 r = dup2(from, to) ; 13 while ((r == -1) && (errno == EINTR)) ; 14 if (r < 0) return r ; 15 fd_close(from) ; 16 return 0 ; 17 }