Changeset 4669 for zzuf


Ignore:
Timestamp:
Oct 6, 2010, 9:33:24 PM (9 years ago)
Author:
Sam Hocevar
Message:

Disable select() on Win32. It is not supported on non-sockets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/zzuf.c

    r4667 r4669  
    944944    tv.tv_usec = 1000;
    945945
    946 #if _WIN32
    947     for(i = 0; i < opts->maxchild; i++)
    948         for (j = 0; j < 3; j++)
    949         {
    950             char tmpbuf[1025];
    951             int tmp = _read(opts->child[i].fd[j], tmpbuf, 1024);
    952             if (tmp > 0)
    953             {
    954                 tmpbuf[tmp] = 0;
    955                 fprintf(stderr, "read %i bytes on fd %i: \"%s\"\n", tmp, j, tmpbuf);
    956             }
    957         }
    958 #endif
    959 
     946#if !defined _WIN32
     947    /* Win32 does not support select() on non-sockets */
    960948    errno = 0;
    961949    ret = select(maxfd + 1, &fdset, NULL, NULL, &tv);
     
    964952    if(ret <= 0)
    965953        return;
     954#endif
    966955
    967956    /* XXX: cute (i, j) iterating hack */
     
    973962            continue;
    974963
     964#if !defined _WIN32
    975965        if(!ZZUF_FD_ISSET(opts->child[i].fd[j], &fdset))
    976966            continue;
     967#endif
    977968
    978969        ret = read(opts->child[i].fd[j], buf, BUFSIZ - 1);
     
    988979                write((j < 2) ? STDERR_FILENO : STDOUT_FILENO, buf, ret);
    989980        }
     981#if !defined _WIN32
    990982        else if(ret == 0)
    991983        {
     
    999991                opts->child[i].status = STATUS_EOF;
    1000992        }
     993#endif
    1001994    }
    1002995}
Note: See TracChangeset for help on using the changeset viewer.