Skip to content

Commit

Permalink
ext/posix: adding POSIX_SC_OPEN_MAX constant.
Browse files Browse the repository at this point in the history
returns the number of file descriptors that a process can handle.
e.g. useful after pcntl_fork() to close all the file descriptors up
to that boundary.

close GH-16681
  • Loading branch information
devnexen committed Nov 2, 2024
1 parent cf5ded9 commit ca5fd05
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ PHP NEWS
its name to be reused. (David Carlier)
. Added Iterable support for pgsql_copy_from. (David Carlier)

- POSIX:
. Added POSIX_SC_OPEN_MAX constant to get the number of file descriptors
a process can handle. (David Carlier)

- Random:
. Moves from /dev/urandom usage to arc4random_buf on Haiku. (David Carlier)

Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ PHP 8.5 UPGRADE NOTES
10. New Global Constants
========================================

- POSIX:
. POSIX_SC_OPEN_MAX.

========================================
11. Changes to INI File Handling
========================================
Expand Down
7 changes: 7 additions & 0 deletions ext/posix/posix.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@
*/
const POSIX_PC_SYMLINK_MAX = UNKNOWN;
#endif
#ifdef _SC_OPEN_MAX
/**
* @var int
* @cvalue _SC_OPEN_MAX
*/
const POSIX_SC_OPEN_MAX = UNKNOWN;
#endif

function posix_kill(int $process_id, int $signal): bool {}

Expand Down
5 changes: 4 additions & 1 deletion ext/posix/posix_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ext/posix/tests/posix_sysconf.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ posix
var_dump(posix_sysconf(-1));
var_dump(posix_errno() != 0);
var_dump(posix_sysconf(POSIX_SC_NPROCESSORS_ONLN));
var_dump(posix_sysconf(POSIX_SC_OPEN_MAX) >= 256);
?>
--EXPECTF--
int(-1)
bool(false)
int(%d)
bool(true)

0 comments on commit ca5fd05

Please sign in to comment.