[BACK]Return to child.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rdist

Diff for /src/usr.bin/rdist/child.c between version 1.19 and 1.20

version 1.19, 2014/07/05 05:08:57 version 1.20, 2014/07/05 06:18:58
Line 462 
Line 462 
 }  }
   
 /*  /*
    * Enable non-blocking I/O mode.
    */
   static int
   setnonblocking(int fd)
   {
           int     mode;
   
           if ((mode = fcntl(fd, F_GETFL)) < 0)
                   return (-1);
           if (mode & O_NONBLOCK)
                   return (0);
           return (fcntl(fd, F_SETFL, mode | O_NONBLOCK));
   }
   
   /*
  * Spawn (create) a new child process for "cmd".   * Spawn (create) a new child process for "cmd".
  */   */
 int  int
Line 510 
Line 525 
                 (void) close(fildes[PIPE_WRITE]);                  (void) close(fildes[PIPE_WRITE]);
   
                 /* Set non-blocking I/O */                  /* Set non-blocking I/O */
                 if (setnonblocking(newchild.c_readfd, TRUE) < 0) {                  if (setnonblocking(newchild.c_readfd) < 0) {
                         error("Set nonblocking I/O failed: %s", SYSERR);                          error("Set nonblocking I/O failed: %s", SYSERR);
                         return(-1);                          return(-1);
                 }                  }
Line 548 
Line 563 
                 return(0);                  return(0);
         }          }
 }  }
   
   
 /*  
  * Enable or disable non-blocking I/O mode.  
  *  
  * Code is from INN by Rich Salz.  
  */  
 #if     NBIO_TYPE == NBIO_IOCTL  
 #include <sys/ioctl.h>  
   
 int  
 setnonblocking(int fd, int flag)  
 {  
         int state;  
   
         state = flag ? 1 : 0;  
         return(ioctl(fd, FIONBIO, (char *)&state));  
 }  
   
 #endif  /* NBIO_IOCTL */  
   
   
 #if     NBIO_TYPE == NBIO_FCNTL  
 int  
 setnonblocking(int fd, int flag)  
 {  
         int     mode;  
   
         if ((mode = fcntl(fd, F_GETFL, 0)) < 0)  
                 return(-1);  
         if (flag)  
                 mode |= FNDELAY;  
         else  
                 mode &= ~FNDELAY;  
         return(fcntl(fd, F_SETFL, mode));  
 }  
 #endif  /* NBIO_FCNTL */  

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20