[php-src] master: ext/pcntl: following up #15921 rework SYS_pidfd_open configure detection. (#18931)
Author: David CARLIER (devnexen)
Committer: GitHub (web-flow)
Pusher: devnexen
Date: 2025-06-24T21:55:00+01:00
Commit: https://github.com/php/php-src/commit/2965fb843d732ff014000c8c293d515d17684bd5
Raw diff: https://github.com/php/php-src/commit/2965fb843d732ff014000c8c293d515d17684bd5.diff
ext/pcntl: following up #15921 rework SYS_pidfd_open configure detection. (#18931)
Changed paths:
M ext/pcntl/config.m4
M ext/pcntl/pcntl.c
Diff:
diff --git a/ext/pcntl/config.m4 b/ext/pcntl/config.m4
index 3efa8a53cad1..cfe6e80ca110 100644
--- a/ext/pcntl/config.m4
+++ b/ext/pcntl/config.m4
@@ -13,7 +13,6 @@ if test "$PHP_PCNTL" != "no"; then
forkx
getcpuid
getpriority
- pidfd_open
pset_bind
pthread_set_qos_class_self_np
rfork
@@ -48,6 +47,9 @@ if test "$PHP_PCNTL" != "no"; then
AC_CHECK_DECLS([SYS_waitid],,,
[#include <sys/syscall.h>])
+ AC_CHECK_DECLS([SYS_pidfd_open],,,
+ [#include <sys/syscall.h>])
+
dnl if unsupported, -1 means automatically ENOSYS in this context
AC_CACHE_CHECK([if sched_getcpu is supported], [php_cv_func_sched_getcpu],
[AC_RUN_IFELSE([AC_LANG_SOURCE([
diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c
index 1f061870ed45..886d4b6b595f 100644
--- a/ext/pcntl/pcntl.c
+++ b/ext/pcntl/pcntl.c
@@ -125,18 +125,20 @@ typedef psetid_t cpu_set_t;
#include <pthread/qos.h>
#endif
-#if defined(__linux__) && defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID ==
1 && defined(HAVE_SYSCALL)
-#define HAVE_LINUX_RAW_SYSCALL_WAITID 1
+#if defined(__linux__) && defined(HAVE_SYSCALL)
+# include <sys/syscall.h>
+# if defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1
+# define HAVE_LINUX_RAW_SYSCALL_WAITID 1
+# endif
+# if defined(HAVE_DECL_SYS_PIDFD_OPEN) && HAVE_DECL_SYS_PIDFD_OPEN == 1
+# define HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN 1
+# endif
#endif
#if defined(HAVE_LINUX_RAW_SYSCALL_WAITID)
#include <unistd.h>
#endif
-#if defined(HAVE_PIDFD_OPEN) || defined(HAVE_LINUX_RAW_SYSCALL_WAITID)
-#include <sys/syscall.h>
-#endif
-
#ifdef HAVE_FORKX
#include <sys/fork.h>
#endif
@@ -1607,7 +1609,7 @@ PHP_FUNCTION(pcntl_forkx)
#endif
/* }}} */
-#ifdef HAVE_PIDFD_OPEN
+#ifdef HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN
// The pidfd_open
syscall is available since 5.3
// and setns
since 3.0.
PHP_FUNCTION(pcntl_setns)
Thread (1 message)
- David CARLIER via GitHub