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
This commit is contained in:
David Carlier 2024-11-02 12:28:08 +00:00
parent cf5ded9cc5
commit ca5fd05536
No known key found for this signature in database
GPG Key ID: 8486F847B4B94EF1
5 changed files with 20 additions and 1 deletions

4
NEWS
View File

@ -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)

View File

@ -117,6 +117,9 @@ PHP 8.5 UPGRADE NOTES
10. New Global Constants
========================================
- POSIX:
. POSIX_SC_OPEN_MAX.
========================================
11. Changes to INI File Handling
========================================

View File

@ -303,6 +303,13 @@ const POSIX_PC_ALLOC_SIZE_MIN = UNKNOWN;
*/
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 {}

View File

@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 82caf527a8ec686bc450e5d782bb79275d5a13e3 */
* Stub hash: 25e0aa769d72988ebca07fff96c8ed1fcb6b7d5e */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_posix_kill, 0, 2, _IS_BOOL, 0)
ZEND_ARG_TYPE_INFO(0, process_id, IS_LONG, 0)
@ -461,4 +461,7 @@ static void register_posix_symbols(int module_number)
#if defined(_PC_SYMLINK_MAX)
REGISTER_LONG_CONSTANT("POSIX_PC_SYMLINK_MAX", _PC_SYMLINK_MAX, CONST_PERSISTENT);
#endif
#if defined(_SC_OPEN_MAX)
REGISTER_LONG_CONSTANT("POSIX_SC_OPEN_MAX", _SC_OPEN_MAX, CONST_PERSISTENT);
#endif
}

View File

@ -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)