@@ -94,23 +94,27 @@ int pthread_fchdir_np(int fd)
94
94
95
95
#if !defined(_WIN32) && defined(HAVE_POSIX_SPAWN)
96
96
// Implementation mostly copied from _CFPosixSpawnFileActionsChdir in swift-corelibs-foundation
97
- static int posix_spawn_file_actions_addchdir (posix_spawn_file_actions_t * __restrict file_actions,
98
- const char * __restrict path) {
97
+ static int posix_spawn_file_actions_addchdir_polyfill (posix_spawn_file_actions_t * __restrict file_actions,
98
+ const char * __restrict path) {
99
99
#if defined(__GLIBC__) && !__GLIBC_PREREQ(2, 29)
100
100
// Glibc versions prior to 2.29 don't support posix_spawn_file_actions_addchdir_np, impacting:
101
101
// - Amazon Linux 2 (EoL mid-2025)
102
102
return ENOSYS;
103
+ #elif defined(__ANDROID__) && __ANDROID_API__ < 34
104
+ // Android versions prior to 14 (API level 34) don't support posix_spawn_file_actions_addchdir_np
105
+ return ENOSYS;
106
+ #elif defined(__OpenBSD__) || defined(__QNX__)
107
+ // Currently missing as of:
108
+ // - OpenBSD 7.5 (April 2024)
109
+ // - QNX 8 (December 2023)
110
+ return ENOSYS;
103
111
#elif defined(__APPLE__) && defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500
104
112
// Conditionally available on macOS if building with a deployment target older than 10.15
105
113
if (__builtin_available (macOS 10.15 , *)) {
106
114
return posix_spawn_file_actions_addchdir_np (file_actions, path);
107
115
}
108
116
return ENOSYS;
109
- #elif defined(__OpenBSD__)
110
- // Currently missing as of:
111
- // - OpenBSD 7.5 (April 2024)
112
- return ENOSYS;
113
- #elif defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || (defined(__ANDROID__) && __ANDROID_API__ >= 34) || defined(__musl__)
117
+ #elif defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__ANDROID__) || defined(__musl__)
114
118
// Pre-standard posix_spawn_file_actions_addchdir_np version available in:
115
119
// - Solaris 11.3 (October 2015)
116
120
// - Glibc 2.29 (February 2019)
@@ -123,7 +127,6 @@ static int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t * __rest
123
127
// Standardized posix_spawn_file_actions_addchdir version (POSIX.1-2024, June 2024) available in:
124
128
// - Solaris 11.4 (August 2018)
125
129
// - NetBSD 10.0 (March 2024)
126
- // - QNX 8 (December 2023)
127
130
return posix_spawn_file_actions_addchdir ((posix_spawn_file_actions_t *)file_actions, path);
128
131
#endif
129
132
}
@@ -1106,7 +1109,7 @@ void spawnProcess(
1106
1109
bool usePosixSpawnChdirFallback = true ;
1107
1110
const auto workingDir = attr.workingDir ;
1108
1111
if (!workingDir.empty () &&
1109
- posix_spawn_file_actions_addchdir (&fileActions, workingDir.c_str ()) != ENOSYS) {
1112
+ posix_spawn_file_actions_addchdir_polyfill (&fileActions, workingDir.c_str ()) != ENOSYS) {
1110
1113
usePosixSpawnChdirFallback = false ;
1111
1114
}
1112
1115
0 commit comments