diff options
Diffstat (limited to 'deps/uv/src/unix/process.c')
-rw-r--r-- | deps/uv/src/unix/process.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c index ffe014514b..10872cce61 100644 --- a/deps/uv/src/unix/process.c +++ b/deps/uv/src/unix/process.c @@ -105,7 +105,7 @@ int uv__make_socketpair(int fds[2], int flags) { int uv__make_pipe(int fds[2], int flags) { -#if HAVE_SYS_PIPE2 +#if __linux__ int fl; fl = O_CLOEXEC; @@ -113,17 +113,11 @@ int uv__make_pipe(int fds[2], int flags) { if (flags & UV__F_NONBLOCK) fl |= O_NONBLOCK; - if (sys_pipe2(fds, fl) == 0) + if (uv__pipe2(fds, fl) == 0) return 0; if (errno != ENOSYS) return -1; - - /* errno == ENOSYS so maybe the kernel headers lied about - * the availability of pipe2(). This can happen if people - * build libuv against newer kernel headers than the kernel - * they actually run the software on. - */ #endif if (pipe(fds)) @@ -180,6 +174,12 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, pid_t pid; int flags; + assert(options.file != NULL); + assert(!(options.flags & ~(UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS | + UV_PROCESS_SETGID | + UV_PROCESS_SETUID))); + + uv__handle_init(loop, (uv_handle_t*)process, UV_PROCESS); loop->counters.process_init++; @@ -269,6 +269,16 @@ int uv_spawn(uv_loop_t* loop, uv_process_t* process, _exit(127); } + if ((options.flags & UV_PROCESS_SETGID) && setgid(options.gid)) { + perror("setgid()"); + _exit(127); + } + + if ((options.flags & UV_PROCESS_SETUID) && setuid(options.uid)) { + perror("setuid()"); + _exit(127); + } + environ = options.env; execvp(options.file, options.args); @@ -368,3 +378,8 @@ uv_err_t uv_kill(int pid, int signum) { return uv_ok_; } } + + +void uv__process_close(uv_process_t* handle) { + ev_child_stop(handle->loop->ev, &handle->child_watcher); +} |