Commit graph

301 commits

Author SHA1 Message Date
David Carlier
6979a7a954
ext/pcntl: Fix pcntl_setcpuaffinity exception type for invalid cpu id.
found while working [on the doc](https://github.com/php/doc-en/pull/4346).

close GH-17474
2025-01-15 20:36:18 +00:00
Gina Peter Banyard
47b262086a
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3:
  ext/pcntl: Fix memory leak in cleanup code of pcntl_exec()
2024-12-15 22:13:54 +00:00
Gina Peter Banyard
2df9f32732
ext/pcntl: Fix memory leak in cleanup code of pcntl_exec() 2024-12-15 22:13:27 +00:00
David Carlier
b8115d6c5e
Fix GH-16769: php_pcntl_set_user_signal_infos aborts when a signal is a reference.
close GH-16772
2024-11-13 12:11:43 +00:00
Gina Peter Bnayard
5853cdb73d Use "must not" instead of "cannot" wording 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
c811d58953 ext/pcntl: Use standard wording for ValueError 2024-08-21 21:12:17 +01:00
Gina Peter Bnayard
e7c4d54d65 Use new helper function for "cannot be empty" ValueErrors 2024-08-21 21:12:17 +01:00
David Carlier
17cf7b381a
ext/pcntl adding Pcntl namespace for Qos class.
Close GH-14892
2024-07-10 19:15:04 +01:00
Vladimir Vrzić
c2fd071db7
ext/pcntl: Added new function pcntl_waitid
to obtain status information pertaining termination, stop, and/or
continue events in one the caller's child processes.

close GH-14617
2024-07-07 11:04:14 +01:00
Peter Kokot
c44834d8ad
Trim trailing whitespace (#14721) 2024-06-29 18:41:45 +02:00
Arnaud Le Blanc
11accb5cdf
Preferably include from build dir (#13516)
* Include from build dir first

This fixes out of tree builds by ensuring that configure artifacts are included
from the build dir.

Before, out of tree builds would preferably include files from the src dir, as
the include path was defined as follows (ignoring includes from ext/ and sapi/) :

    -I$(top_builddir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/main
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM
    -I$(top_builddir)/

As a result, an out of tree build would include configure artifacts such as
`main/php_config.h` from the src dir.

After this change, the include path is defined as follows:

    -I$(top_builddir)/main
    -I$(top_builddir)
    -I$(top_srcdir)/main
    -I$(top_srcdir)
    -I$(top_builddir)/TSRM
    -I$(top_builddir)/Zend
    -I$(top_srcdir)/Zend
    -I$(top_srcdir)/TSRM

* Fix extension include path for out of tree builds

* Include config.h with the brackets form

`#include "config.h"` searches in the directory containing the including-file
before any other include path. This can include the wrong config.h when building
out of tree and a config.h exists in the source tree.

Using `#include <config.h>` uses exclusively the include path, and gives
priority to the build dir.
2024-06-26 00:26:43 +02:00
Gina Peter Banyard
fd2d869642
Clean-up some more headers (#14416)
Remove unused headers (such as php_ini.h for extensions that don't define INI settings)
Use more specific headers when possible
2024-06-08 17:15:36 +01:00
Gina Peter Banyard
2fa3e8094c ext/pcntl: Fix [-Wsign-compare] warnings 2024-06-06 16:18:23 +01:00
David Carlier
fe7f699c0a
ext/pcntl: adding SIGTRAP handling for freebsd.
if a restricted file descriptor based syscall by the system had been attempted,
a SIGTRAP is raised with the syscall id.

close GH-14266
2024-05-22 18:40:58 +01:00
David CARLIER
4ed1835f00
ext/pcntl: cpu affinity support for solaris/illumos. (#14199) 2024-05-15 19:43:27 +01:00
David Carlier
19c8a10f3f
ext/pcntl: add pcntl_getcpu support for solaris.
using getcpuid having similar signature too.

close GH-14188
2024-05-11 05:53:10 +01:00
David CARLIER
32936c518a
ext/pcntl: porting pcntl cpu affinity api to netbsd. (#14056) 2024-04-29 13:54:07 +01:00
David CARLIER
23640542dc
ext/pcntl: pcntl_fork refining error handling. (#14021) 2024-04-20 21:01:09 +01:00
David Carlier
d40726670f
ext/pcntl: pcntl_getqos_class/pcntl_setqos_class addition.
Introducting macOs Quality Of Service through those two calls.
on macOs arm64/M*, there is no concept of individual cores, thus
the old thread policy for cpu affinity does not work here.
Instead, the user can apply to the current process the level of
 performance/energy consumption they wish from the highest
QosClass::UserInteractive to QosClass::Background.

Close GH-13945
2024-04-15 18:52:28 +01:00
David CARLIER
7c860628cd
ext/pcntl: getpriority/setpriority who default value handling change. (#13911)
0 refers to the calling process, all across unixes, thus saving one
syscall.
2024-04-07 22:30:48 +01:00
David Carlier
d8f2900574
ext/pcntl: adding pcntl_getcpu.
using sched_getcpu under the hood (Linux and FreeBSD).
Returns the current cpu id for the current process.
For Linux, we need to see beyond the sole presence of the symbol
to consider it.
Mostly useful, for now, in the cpu affinity context since
the os can migrate processes as it sees fits otherwise.

Clos GH-13908
2024-04-07 20:05:03 +01:00
David CARLIER
dd2ffaab2c
ext/pcntl: pcntl affinity improves EINVAL handling in both cases. (#13907)
also disable tests on travis.
2024-04-07 16:43:36 +01:00
David Carlier
01817e99ab
ext/pcntl pcntl_signal_get_handler update.
The situation varies from platform to another, thus taking in
account the complexity of it.

Close GH-13902
2024-04-07 13:25:45 +01:00
David Carlier
1cf8291c85
ext/pcntl: cpu affinity api introduction.
For now, working on Linux, FreeBSD >= 13.x and DragonFlyBSD.
Handy wrapper to assign an array of cpu ids or to retrieve the cpu ids
assigned to a given process.

pcntl_setaffinity inserts valid unique cpu ids (within the range of available
cpus).

Close GH-13893
2024-04-07 00:56:54 +01:00
David CARLIER
2508138532
ext/pcntl: pcnt_setns few nitpicks changes. (#13885) 2024-04-04 21:05:35 +01:00
David Carlier
ae4978a139
ext/pcntl: adding pcntl_setns for Linux >= 5.3
allows a given process to join an existing Linux namespace, relatively
complementary to the existing pcntl_unshare.

Close GH-13878
2024-04-04 18:45:15 +01:00
David CARLIER
7db7c420f1
ext/pcntl: pcntl_unshare minor error message clarification (for EINVAL). (#13872)
it is not necessarily a bad flag but can just be unsupported by the
current kernel.
2024-04-02 23:26:07 +01:00
Gina Peter Banyard
1bdb0fddc1
Refactor pcntl_sigprocmask()/pcntl_sigwaitinfo()/pcntl_sigtimedwait() (#11860) 2023-11-16 00:40:18 +00:00
Niels Dossche
5465cea8c8
Remove unused variable 'error' (#12438)
Will also get rid of the potential allocation happening in
zend_is_callable_ex().
2023-10-15 18:24:18 +02:00
George Peter Banyard
bc4807c506
ext/pcntl: Remove useless call to zend_get_callable_name() (#12241)
Result of it is unused
2023-09-18 17:35:36 +01:00
Niels Dossche
633e7455e5 Merge branch 'PHP-8.2'
* PHP-8.2:
  Revert the fix for GH-11498
2023-08-03 21:59:35 +02:00
Niels Dossche
c59bfc8d98 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Revert the fix for GH-11498
2023-08-03 21:59:21 +02:00
Niels Dossche
f7be15dbad Revert the fix for GH-11498
People relied on manually waiting for children, but the fix for GH-11498
broke this. Fixing this in PHP is fundamentally incompatible with doing
the wait loop in userland. This reverts to the old behaviour.

Closes GH-11863.
2023-08-03 21:48:34 +02:00
Ilija Tovilo
149fb8fc34
Merge branch 'PHP-8.2'
* PHP-8.2:
  Use waitpid(-1) over WAIT_ANY
2023-07-04 10:29:22 +02:00
Ilija Tovilo
60dd88c93e
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Use waitpid(-1) over WAIT_ANY
2023-07-04 10:29:14 +02:00
Ilija Tovilo
46e9c5104c
Use waitpid(-1) over WAIT_ANY
This macro is only available in glibc.

Closes GH-11588
2023-07-04 10:28:59 +02:00
Ilija Tovilo
db2ac3a656
Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix use of uninitialized memory in pcntl SIGCHLD handling
2023-06-27 11:03:48 +02:00
Ilija Tovilo
7d188491c4
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix use of uninitialized memory in pcntl SIGCHLD handling
2023-06-27 11:03:42 +02:00
Ilija Tovilo
003cf9da78
Fix use of uninitialized memory in pcntl SIGCHLD handling
psig needs to stay the tail, so that we don't get a dangling element on the end.

Closes GH-11536
2023-06-27 11:02:59 +02:00
Niels Dossche
2209f7508b Merge branch 'PHP-8.2'
* PHP-8.2:
  Add missing WUNTRACED
2023-06-25 11:18:25 +02:00
Niels Dossche
a8bf8e37a9 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Add missing WUNTRACED
2023-06-25 11:18:15 +02:00
Niels Dossche
931d8d059b Add missing WUNTRACED
I forgot to add this in GH-11509.

Closes GH-11526.
2023-06-25 11:17:59 +02:00
Niels Dossche
0de8bc270d Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix GH-11498: SIGCHLD is not always returned from proc_open
2023-06-23 22:04:40 +02:00
Niels Dossche
022b6aa4cb Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  Fix GH-11498: SIGCHLD is not always returned from proc_open
2023-06-23 21:58:05 +02:00
nielsdos
f39b513916 Fix GH-11498: SIGCHLD is not always returned from proc_open
Linux, and maybe other unixes, may merge multiple standard signals into
a single one. This causes issues when keeping track of process IDs.
Solve this by manually checking which children are dead using waitpid().

Test case is based on taka-oyama's test code.

Closes GH-11509.
2023-06-23 21:56:21 +02:00
Niels Dossche
80efa76b8b Merge branch 'PHP-8.2'
* PHP-8.2:
  Fix maximum argument count of pcntl_forkx()
2023-05-06 21:00:30 +02:00
Niels Dossche
a0e71cb811 Fix maximum argument count of pcntl_forkx()
Closes GH-11199.
2023-05-06 20:56:27 +02:00
Arnaud Le Blanc
0c7fc351ea Merge branch 'PHP-8.2'
* PHP-8.2:
  [ci skip] NEWS
  [ci skip] NEWS
  fix: support for timeouts with ZTS on Linux (#10141)
2023-03-03 11:56:34 +01:00
Arnaud Le Blanc
37030257b8 Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1:
  [ci skip] NEWS
  fix: support for timeouts with ZTS on Linux (#10141)
2023-03-03 11:45:50 +01:00
Kévin Dunglas
ad85e71421
fix: support for timeouts with ZTS on Linux (#10141) 2023-03-03 11:35:06 +01:00