Skip to content

Commit

Permalink
Reland "macos: use posix_spawn instead of fork" (libuv#3257)
Browse files Browse the repository at this point in the history
Fixes: libuv#3050
Refs: libuv#3086
Refs: libuv#3064
Refs: libuv#3107
Refs: libuv#3064

This reverts commit 217fdf4, then fixes
several issues with it:

* remove error fast-cleanup code that triggers a nodejs bug

Refs: libuv#3107 (comment)

* protect posix_spawn from EINTR

This is not a documented valid error, but seems to have been observed.

* ignore setuid/setgid syscall

This kernel function is not permitted unless the process is setuid root,
so disable this syscall. Falling back to fork/exec should be okay for
the rare cases that the user decides they need to do setuid(getuid()) or
setuid(geteuid()) for the child.

Refs: libuv#3107 (comment)

* improve posix_spawn path search

Ports the improvements in musl back to this function

* fix some additional problems and formatting issues

We previously might fail to start a watcher, in rare failure cases,
resulting in a zombie that we would fail to kill. Also avoid creating
the signal-pipe unless required (addresses a review comment from Apple)

* fix fd->fd mapping reuse

There was a chance that when duplicating the fd's into stdio_count+fd we
might be closing a currently opened fd with that value.
  • Loading branch information
vtjnash authored and JeffroMF committed May 16, 2022
1 parent 0b233b0 commit b150b24
Showing 1 changed file with 608 additions and 119 deletions.
Loading

0 comments on commit b150b24

Please sign in to comment.