Skip to content

Commit ca5fd05

Browse files
committed
ext/posix: adding POSIX_SC_OPEN_MAX constant.
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
1 parent cf5ded9 commit ca5fd05

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PHP NEWS
2525
its name to be reused. (David Carlier)
2626
. Added Iterable support for pgsql_copy_from. (David Carlier)
2727

28+
- POSIX:
29+
. Added POSIX_SC_OPEN_MAX constant to get the number of file descriptors
30+
a process can handle. (David Carlier)
31+
2832
- Random:
2933
. Moves from /dev/urandom usage to arc4random_buf on Haiku. (David Carlier)
3034

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ PHP 8.5 UPGRADE NOTES
117117
10. New Global Constants
118118
========================================
119119

120+
- POSIX:
121+
. POSIX_SC_OPEN_MAX.
122+
120123
========================================
121124
11. Changes to INI File Handling
122125
========================================

ext/posix/posix.stub.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,13 @@
303303
*/
304304
const POSIX_PC_SYMLINK_MAX = UNKNOWN;
305305
#endif
306+
#ifdef _SC_OPEN_MAX
307+
/**
308+
* @var int
309+
* @cvalue _SC_OPEN_MAX
310+
*/
311+
const POSIX_SC_OPEN_MAX = UNKNOWN;
312+
#endif
306313

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

ext/posix/posix_arginfo.h

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/posix/tests/posix_sysconf.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ posix
77
var_dump(posix_sysconf(-1));
88
var_dump(posix_errno() != 0);
99
var_dump(posix_sysconf(POSIX_SC_NPROCESSORS_ONLN));
10+
var_dump(posix_sysconf(POSIX_SC_OPEN_MAX) >= 256);
1011
?>
1112
--EXPECTF--
1213
int(-1)
1314
bool(false)
1415
int(%d)
16+
bool(true)

0 commit comments

Comments
 (0)