diff options
author | Brad King <brad.king@kitware.com> | 2024-03-25 16:00:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-03-25 16:11:57 (GMT) |
commit | e3e2ef19645d8e6b9da3309bedff7ab3d13ee605 (patch) | |
tree | 8c50b63a10713538d1b734e9e4cf2e807e421e6c /Utilities/cmlibuv | |
parent | b5602e7254c8ce4a6f732c017d784cd80559e5aa (diff) | |
download | CMake-e3e2ef19645d8e6b9da3309bedff7ab3d13ee605.zip CMake-e3e2ef19645d8e6b9da3309bedff7ab3d13ee605.tar.gz CMake-e3e2ef19645d8e6b9da3309bedff7ab3d13ee605.tar.bz2 |
libuv: Avoid posix_spawn on macOS < 10.8
Since libuv commit `83efa3dd71` (Reland "macos: use posix_spawn instead
of fork", 2022-03-02, v1.44.0~10), `uv_spawn` on macOS < 10.8
has been observed to cause kernel panics and/or resource exhaustion.
This became particularly noticeable in CMake since commit 5420639a8d
(cmExecuteProcessCommand: Replace cmsysProcess with cmUVProcessChain,
2023-06-01, v3.28.0-rc1~138^2~8). Prefer `fork` over `posix_spawn` in
libuv when targeting macOS < 10.8.
Fixes: #25414
Fixes: #25818
Inspired-by: Ken Cunningham <kencu@macports.org>
Diffstat (limited to 'Utilities/cmlibuv')
-rw-r--r-- | Utilities/cmlibuv/src/unix/process.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Utilities/cmlibuv/src/unix/process.c b/Utilities/cmlibuv/src/unix/process.c index 39ec451..5c39da6 100644 --- a/Utilities/cmlibuv/src/unix/process.c +++ b/Utilities/cmlibuv/src/unix/process.c @@ -37,7 +37,11 @@ #include <sched.h> #if defined(__APPLE__) -# include <spawn.h> + /* macOS 10.8 and later have a working posix_spawn */ +# if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 +# define UV_USE_APPLE_POSIX_SPAWN +# include <spawn.h> +# endif # include <paths.h> # include <sys/kauth.h> # include <sys/types.h> @@ -430,7 +434,7 @@ static void uv__process_child_init(const uv_process_options_t* options, #endif -#if defined(__APPLE__) +#if defined(UV_USE_APPLE_POSIX_SPAWN) typedef struct uv__posix_spawn_fncs_tag { struct { int (*addchdir_np)(const posix_spawn_file_actions_t *, const char *); @@ -882,7 +886,7 @@ static int uv__spawn_and_init_child( int exec_errorno; ssize_t r; -#if defined(__APPLE__) +#if defined(UV_USE_APPLE_POSIX_SPAWN) uv_once(&posix_spawn_init_once, uv__spawn_init_posix_spawn); /* Special child process spawn case for macOS Big Sur (11.0) onwards |