diff --git a/src/lib/fd.c b/src/lib/fd.c index 5b2043b90..8a96307a7 100644 --- a/src/lib/fd.c +++ b/src/lib/fd.c @@ -169,10 +169,14 @@ int ncfdplane_destroy(ncfdplane* n){ // ncfdplane around the read end, involving creation of a new thread. the // parent then returns. static pid_t -launch_pipe_process(int* pipe, int* pidfd){ +launch_pipe_process(int* pipefd, int* pidfd){ *pidfd = -1; int pipes[2]; +#if (defined(__linux__)) if(pipe2(pipes, O_CLOEXEC)){ // can't use O_NBLOCK here (affects client) +#else + if(pipe(pipes)){ // FIXME manually set O_CLOEXEC +#endif return -1; } pid_t p = -1; @@ -197,8 +201,8 @@ launch_pipe_process(int* pipe, int* pidfd){ exit(EXIT_FAILURE); } }else if(p > 0){ // parent - *pipe = pipes[0]; - set_fd_nonblocking(*pipe, 1, NULL); + *pipefd = pipes[0]; + set_fd_nonblocking(*pipefd, 1, NULL); } return p; } @@ -392,6 +396,9 @@ ncsubproc* ncsubproc_createvpe(ncplane* n, const ncsubproc_options* opts, if(ret->pid == 0){ #ifdef __linux__ execvpe(bin, arg, env); +#elif defined(__APPLE__) + (void)env; + execvp(bin, arg); // FIXME env? #else exect(bin, arg, env); #endif diff --git a/src/lib/input.c b/src/lib/input.c index a8b3838d7..7b0be653a 100644 --- a/src/lib/input.c +++ b/src/lib/input.c @@ -406,7 +406,12 @@ block_on_input(int fd, const struct timespec* ts, const sigset_t* sigmask){ pfd.events |= POLLRDHUP; #endif int events; +#ifdef __APPLE__ + int timeoutms = ts->tv_sec * 1000 + ts->tv_nsec / 1000000; + while((events = poll(&pfd, 1, timeoutms)) < 0){ // FIXME scratchmask? +#else while((events = ppoll(&pfd, 1, ts, &scratchmask)) < 0){ +#endif if(events == 0){ return 0; }