Changeset 1758 for zzuf


Ignore:
Timestamp:
Feb 24, 2007, 5:20:42 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Minor win32 cosmetic updates.
File:
1 edited

Legend:

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

    r1744 r1758  
    536536static void spawn_children(struct opts *opts)
    537537{
    538     int fd[3][2];
     538    int pipes[3][2];
    539539    int64_t now = _zz_time();
    540540    pid_t pid;
     
    563563        int ret;
    564564#if defined HAVE_PIPE
    565         ret = pipe(fd[j]);
     565        ret = pipe(pipes[j]);
    566566#elif defined HAVE__PIPE
    567         ret = _pipe(fd[j], 256, _O_BINARY);
     567        ret = _pipe(pipes[j], 512, _O_BINARY | O_NOINHERIT);
    568568#endif
    569569        if(ret < 0)
     
    574574    }
    575575
    576     pid = run_process(opts, fd);
     576    pid = run_process(opts, pipes);
    577577    if(pid < 0)
    578578        return;
     
    583583    for(j = 0; j < 3; j++)
    584584    {
    585         close(fd[j][1]);
    586         opts->child[i].fd[j] = fd[j][0];
     585        close(pipes[j][1]);
     586        opts->child[i].fd[j] = pipes[j][0];
    587587    }
    588588    opts->child[i].bytes = 0;
     
    756756        if(!ZZUF_FD_ISSET(opts->child[i].fd[j], &fdset))
    757757            continue;
     758fprintf(stderr, "data on fd %i for process %i\n", j, i);
    758759
    759760        ret = read(opts->child[i].fd[j], buf, BUFSIZ - 1);
     
    833834#endif
    834835
    835 static int run_process(struct opts *opts, int fd[][2])
     836static int run_process(struct opts *opts, int pipes[][2])
    836837{
    837838    char buf[64];
     
    874875    for(j = 3; j--; )
    875876    {
    876         close(fd[j][0]);
    877         if(fd[j][1] != files[j])
    878         {
    879             dup2(fd[j][1], files[j]);
    880             close(fd[j][1]);
     877        close(pipes[j][0]);
     878        if(pipes[j][1] != files[j])
     879        {
     880            dup2(pipes[j][1], files[j]);
     881            close(pipes[j][1]);
    881882        }
    882883    }
     
    935936    memset(&sinfo, 0, sizeof(sinfo));
    936937    sinfo.cb = sizeof(sinfo);
    937     DuplicateHandle(pid, (HANDLE)_get_osfhandle(fd[0][1]), pid,
     938    DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[0][1]), pid,
    938939        /* FIXME */ &sinfo.hStdInput, 0, TRUE, DUPLICATE_SAME_ACCESS);
    939     DuplicateHandle(pid, (HANDLE)_get_osfhandle(fd[1][1]), pid,
     940    DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[1][1]), pid,
    940941                    &sinfo.hStdError, 0, TRUE, DUPLICATE_SAME_ACCESS);
    941     DuplicateHandle(pid, (HANDLE)_get_osfhandle(fd[2][1]), pid,
     942    DuplicateHandle(pid, (HANDLE)_get_osfhandle(pipes[2][1]), pid,
    942943                    &sinfo.hStdOutput, 0, TRUE, DUPLICATE_SAME_ACCESS);
    943944    sinfo.dwFlags = STARTF_USESTDHANDLES;
Note: See TracChangeset for help on using the changeset viewer.