C LibUV进程和waitpid()

C LibUV进程和waitpid(),c,windows,waitpid,libuv,C,Windows,Waitpid,Libuv,我正在VisualStudio15上使用LibUV创建一个进程 我想这样做: createsProcess() { pid_t pid; pid = myspawn(cmd, argv, my_fds, 1); while(waitpid(&pid, child_status,0 == -1 && errno = EINTR)); } } 流程创建代码: pid_t myspawn(char* cmd, char **argv, int*

我正在VisualStudio15上使用LibUV创建一个进程

我想这样做:

createsProcess() {
    pid_t pid;
    pid = myspawn(cmd, argv, my_fds, 1);
    while(waitpid(&pid, child_status,0 == -1 && errno = EINTR));
    }
}
流程创建代码:

pid_t myspawn(char* cmd, char **argv, int* mapped_fds) {
            pid_t pid;
            extern char** environ;
            uv_loop_t *loop;
            uv_process_t child_req;
            uv_process_options_t options = { 0 }; //-- Default initialization must be 0
            loop = uv_default_loop();
            //-- Container for file descriptor
            uv_stdio_container_t child_stdio[3];
            child_stdio[0].flags = UV_IGNORE;
            child_stdio[1].flags = UV_INHERIT_FD; //STD_OUT should be redirected to calling function
            child_stdio[2].flags = UV_IGNORE;

            // Pass stdout of created process to parent passed descriptor.
            if (mapped_fds != NULL) {
                for (; *mapped_fds != -1; mapped_fds += 2) {
                    if (mapped_fds[1] != -1)
                         child_stdio[1].data.fd = mapped_fds[0]; 
                }
            }

            options.stdio = child_stdio;
            options.exit_cb = on_exit;  
            options.file = cmd;
            options.args = argv;
            options.env = environ;
            errno = uv_spawn(loop,&child_req,&options);
            pid = child_req.pid;

            if (errno != 0)
                return -1;

            return pid;
        } 
问题是windows不支持waitpid(),我在LibUV中找不到完全相同的替代方法。但是,我只能在子进程退出时调用类似on_exit的函数。但这无助于我等待它

任何帮助都将不胜感激


最佳

为什么要主动旋转?