Skip to content

Commit 293b38b

Browse files
committed
Fix macOS posix_spawn_file_actions_addchdir availability handling
1 parent 555e652 commit 293b38b

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

ext/standard/proc_open.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,26 @@
4747
#define USE_POSIX_SPAWN
4848

4949
/* The non-_np variant is in macOS 26 (and _np deprecated) */
50-
#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
51-
#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir
50+
static inline int php_spawn_addchdir(
51+
posix_spawn_file_actions_t *factions,
52+
const char *cwd
53+
) {
54+
#if defined(__APPLE__)
55+
if (__builtin_available(macOS 26.0, *)) {
56+
return posix_spawn_file_actions_addchdir(factions, cwd);
57+
} else {
58+
return posix_spawn_file_actions_addchdir_np(factions, cwd);
59+
}
60+
#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)
61+
return posix_spawn_file_actions_addchdir(factions, cwd);
5262
#else
53-
#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np
63+
return posix_spawn_file_actions_addchdir_np(factions, cwd);
5464
#endif
65+
}
66+
67+
#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(f, d) \
68+
php_spawn_addchdir((f), (d))
69+
5570
#endif
5671

5772
/* This symbol is defined in ext/standard/config.m4.

0 commit comments

Comments
 (0)