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

Diff for /src/usr.bin/sendbug/atomicio.c between version 1.2 and 1.3

version 1.2, 2007/07/31 03:44:21 version 1.3, 2007/09/07 14:50:44
Line 27 
Line 27 
  */   */
   
 #include <sys/param.h>  #include <sys/param.h>
 #include <sys/uio.h>  
   
 #include <errno.h>  #include <errno.h>
   #include <poll.h>
   #include <unistd.h>
   
 #include "atomicio.h"  #include "atomicio.h"
   
Line 42 
Line 43 
         char *s = _s;          char *s = _s;
         size_t pos = 0;          size_t pos = 0;
         ssize_t res;          ssize_t res;
           struct pollfd pfd;
   
           pfd.fd = fd;
           pfd.events = f == read ? POLLIN : POLLOUT;
         while (n > pos) {          while (n > pos) {
                 res = (f) (fd, s + pos, n - pos);                  res = (f) (fd, s + pos, n - pos);
                 switch (res) {                  switch (res) {
                 case -1:                  case -1:
                         if (errno == EINTR || errno == EAGAIN)                          if (errno == EINTR)
                                 continue;                                  continue;
                           if (errno == EAGAIN) {
                                   (void)poll(&pfd, 1, -1);
                                   continue;
                           }
                         return 0;                          return 0;
                 case 0:                  case 0:
                         errno = EPIPE;                          errno = EPIPE;

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3