Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ext/pcntl/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if test "$PHP_PCNTL" != "no"; then
forkx
getcpuid
getpriority
pidfd_open
pset_bind
pthread_set_qos_class_self_np
rfork
Expand Down Expand Up @@ -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([
Expand Down
16 changes: 9 additions & 7 deletions ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down