mirror of
https://github.com/electron/electron.git
synced 2026-01-09 15:38:08 -05:00
* fix: libuv patches to address child_process.spawn slowness * chore: backport additional patches Co-authored-by: deepak1556 <hop2deep@gmail.com>
55 lines
1.8 KiB
Diff
55 lines
1.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ben Noordhuis <info@bnoordhuis.nl>
|
|
Date: Wed, 9 Mar 2022 11:06:39 +0100
|
|
Subject: macos: don't use thread-unsafe strtok() (#3524)
|
|
|
|
Refs https://github.com/libuv/libuv/pull/3524
|
|
|
|
diff --git a/deps/uv/src/unix/process.c b/deps/uv/src/unix/process.c
|
|
index 8cde389b826b6b167437845eccd5fed440dcadc4..147164e7ea25abbf655452930d78ee0a714cce36 100644
|
|
--- a/deps/uv/src/unix/process.c
|
|
+++ b/deps/uv/src/unix/process.c
|
|
@@ -387,30 +387,22 @@ static void uv__spawn_init_posix_spawn_fncs(void) {
|
|
|
|
|
|
static void uv__spawn_init_can_use_setsid(void) {
|
|
- static const int MACOS_CATALINA_VERSION_MAJOR = 19;
|
|
- char version_str[256];
|
|
- char* version_major_str;
|
|
- size_t version_str_size = 256;
|
|
- int r;
|
|
- int version_major;
|
|
-
|
|
- /* Get a version string */
|
|
- r = sysctlbyname("kern.osrelease", version_str, &version_str_size, NULL, 0);
|
|
- if (r != 0)
|
|
+ int which[] = {CTL_KERN, KERN_OSRELEASE};
|
|
+ unsigned major;
|
|
+ unsigned minor;
|
|
+ unsigned patch;
|
|
+ char buf[256];
|
|
+ size_t len;
|
|
+
|
|
+ len = sizeof(buf);
|
|
+ if (sysctl(which, ARRAY_SIZE(which), buf, &len, NULL, 0))
|
|
return;
|
|
|
|
- /* Try to get the major version number. If not found
|
|
- * fall back to the fork/exec flow */
|
|
- version_major_str = strtok(version_str, ".");
|
|
- if (version_major_str == NULL)
|
|
+ /* NULL specifies to use LC_C_LOCALE */
|
|
+ if (3 != sscanf_l(buf, NULL, "%u.%u.%u", &major, &minor, &patch))
|
|
return;
|
|
|
|
- /* Parse the version major as a number. If it is greater than
|
|
- * the major version for macOS Catalina (aka macOS 10.15), then
|
|
- * the POSIX_SPAWN_SETSID flag is available */
|
|
- version_major = atoi_l(version_major_str, NULL); /* Use LC_C_LOCALE */
|
|
- if (version_major >= MACOS_CATALINA_VERSION_MAJOR)
|
|
- posix_spawn_can_use_setsid = 1;
|
|
+ posix_spawn_can_use_setsid = (major >= 19); /* macOS Catalina */
|
|
}
|
|
|
|
|