Skip to content

Commit 2965fb8

Browse files
authored
ext/pcntl: following up #15921 rework SYS_pidfd_open configure detection. (#18931)
1 parent 720917f commit 2965fb8

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

ext/pcntl/config.m4

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ if test "$PHP_PCNTL" != "no"; then
1313
forkx
1414
getcpuid
1515
getpriority
16-
pidfd_open
1716
pset_bind
1817
pthread_set_qos_class_self_np
1918
rfork
@@ -48,6 +47,9 @@ if test "$PHP_PCNTL" != "no"; then
4847
AC_CHECK_DECLS([SYS_waitid],,,
4948
[#include <sys/syscall.h>])
5049

50+
AC_CHECK_DECLS([SYS_pidfd_open],,,
51+
[#include <sys/syscall.h>])
52+
5153
dnl if unsupported, -1 means automatically ENOSYS in this context
5254
AC_CACHE_CHECK([if sched_getcpu is supported], [php_cv_func_sched_getcpu],
5355
[AC_RUN_IFELSE([AC_LANG_SOURCE([

ext/pcntl/pcntl.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,20 @@ typedef psetid_t cpu_set_t;
125125
#include <pthread/qos.h>
126126
#endif
127127

128-
#if defined(__linux__) && defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1 && defined(HAVE_SYSCALL)
129-
#define HAVE_LINUX_RAW_SYSCALL_WAITID 1
128+
#if defined(__linux__) && defined(HAVE_SYSCALL)
129+
# include <sys/syscall.h>
130+
# if defined(HAVE_DECL_SYS_WAITID) && HAVE_DECL_SYS_WAITID == 1
131+
# define HAVE_LINUX_RAW_SYSCALL_WAITID 1
132+
# endif
133+
# if defined(HAVE_DECL_SYS_PIDFD_OPEN) && HAVE_DECL_SYS_PIDFD_OPEN == 1
134+
# define HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN 1
135+
# endif
130136
#endif
131137

132138
#if defined(HAVE_LINUX_RAW_SYSCALL_WAITID)
133139
#include <unistd.h>
134140
#endif
135141

136-
#if defined(HAVE_PIDFD_OPEN) || defined(HAVE_LINUX_RAW_SYSCALL_WAITID)
137-
#include <sys/syscall.h>
138-
#endif
139-
140142
#ifdef HAVE_FORKX
141143
#include <sys/fork.h>
142144
#endif
@@ -1607,7 +1609,7 @@ PHP_FUNCTION(pcntl_forkx)
16071609
#endif
16081610
/* }}} */
16091611

1610-
#ifdef HAVE_PIDFD_OPEN
1612+
#ifdef HAVE_LINUX_RAW_SYSCALL_PIDFD_OPEN
16111613
// The `pidfd_open` syscall is available since 5.3
16121614
// and `setns` since 3.0.
16131615
PHP_FUNCTION(pcntl_setns)

0 commit comments

Comments
 (0)