nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

fd_copy.c (236B)


      1 #include <fcntl.h>
      2 #include <unistd.h>
      3 #include "fd.h"
      4 
      5 int fd_copy(int to, int from)
      6 {
      7   if (to == from) return 0;
      8   if (fcntl(from,F_GETFL,0) == -1) return -1;
      9   close(to);
     10   if (fcntl(from,F_DUPFD,to) == -1) return -1;
     11   return 0;
     12 }