Commit c3a1214ef99 for php.net

commit c3a1214ef9975b537339196da6645ee9c5dc4667
Author: Calvin Buckley <calvinb@php.net>
Date:   Mon Mar 30 09:27:54 2026 -0400

    ext/standard: Use posix_spawn_file_actions_addchdir when available (#21553)

    posix_spawn_file_actions_addchdir is part of POSIX now, so some OSes
    (macOS at least) have started to deprecated the _np variant. Some
    support both names (Solaris, NetBSD), others don't yet (FreeBSD).

    Use the non-np variant when possible to avoid the deprecation warning on
    macOS and other platforms in the future.

    Fixes GH-21552

diff --git a/ext/standard/config.m4 b/ext/standard/config.m4
index ef6b3c5a010..1d64c7ff696 100644
--- a/ext/standard/config.m4
+++ b/ext/standard/config.m4
@@ -328,7 +328,7 @@ dnl

 PHP_CHECK_FUNC(res_search, resolv, socket)

-AC_CHECK_FUNCS([posix_spawn_file_actions_addchdir_np elf_aux_info])
+AC_CHECK_FUNCS([posix_spawn_file_actions_addchdir posix_spawn_file_actions_addchdir_np elf_aux_info])

 dnl
 dnl Obsolete check for strptime() declaration. The strptime, where available,
diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c
index 55f4dd48495..a393a2a1f88 100644
--- a/ext/standard/proc_open.c
+++ b/ext/standard/proc_open.c
@@ -35,7 +35,7 @@
 #include <fcntl.h>
 #endif

-#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP
+#if defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP) || defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)
 /* Only defined on glibc >= 2.29, FreeBSD CURRENT, musl >= 1.1.24,
  * MacOS Catalina or later..
  * It should be possible to modify this so it is also
@@ -45,6 +45,13 @@
  */
 #include <spawn.h>
 #define USE_POSIX_SPAWN
+
+/* The non-_np variant is in macOS 26 (and _np deprecated) */
+#ifdef HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR
+#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir
+#else
+#define POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR posix_spawn_file_actions_addchdir_np
+#endif
 #endif

 /* This symbol is defined in ext/standard/config.m4.
@@ -1394,9 +1401,9 @@ PHP_FUNCTION(proc_open)
 	}

 	if (cwd) {
-		r = posix_spawn_file_actions_addchdir_np(&factions, cwd);
+		r = POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR(&factions, cwd);
 		if (r != 0) {
-			php_error_docref(NULL, E_WARNING, "posix_spawn_file_actions_addchdir_np() failed: %s", strerror(r));
+			php_error_docref(NULL, E_WARNING, ZEND_TOSTR(POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR) "() failed: %s", strerror(r));
 		}
 	}