From 5faa54d93bd5b30397352a9534b4df964a1d75e0 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 19 Dec 2025 12:49:17 +0000 Subject: [PATCH] ext/pcntl: fix pcntl_getcpuaffinity() for solaris. trusting the call to handle invalid process id via errnos. see https://github.com/php/php-src/pull/20709#discussion_r2630221301 for rationale. close GH-20731 --- NEWS | 4 ++++ ext/pcntl/pcntl.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7dca021c37623..2fb8cd3620fec 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,10 @@ PHP NEWS . Fixed bug GH-20674 (mb_decode_mimeheader does not handle separator). (Yuya Hamada) +- PCNTL: + . Fixed bug with pcntl_getcpuaffinity() on solaris regarding invalid + process ids handling. (David Carlier) + - Phar: . Fixed bug GH-20732 (Phar::LoadPhar undefined behavior when reading fails). (ndossche) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 27e0c90dc96f0..2034ca80b05b8 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -93,7 +93,7 @@ typedef cpuset_t *cpu_set_t; #elif defined(HAVE_PSET_BIND) #include typedef psetid_t cpu_set_t; - #define sched_getaffinity(p, c, m) pset_bind(PS_QUERY, P_PID, (p <= 0 ? getpid() : p), &m) + #define sched_getaffinity(p, c, m) pset_bind(PS_QUERY, P_PID, p, &m) #define sched_setaffinity(p, c, m) pset_bind(m, P_PID, (p <= 0 ? getpid() : p), NULL) #define PCNTL_CPUSET(mask) mask #define PCNTL_CPU_ISSET(i, mask) (pset_assign(PS_QUERY, (processorid_t)i, &query) == 0 && query == mask)