Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/posix/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
#define POSIX_PID_MAX INT_MAX
#endif

/* RLIM_INFINITY does not fit into a 32-bit zend_long if rlim_t is 64-bit.
* posix_setrlimit() maps -1 to RLIM_INFINITY, so use that in this case. */
#define PHP_POSIX_RLIM_INFINITY (RLIM_INFINITY > ZEND_LONG_MAX ? -1 : (zend_long) RLIM_INFINITY)

#include "posix_arginfo.h"

ZEND_DECLARE_MODULE_GLOBALS(posix)
Expand Down
2 changes: 1 addition & 1 deletion ext/posix/posix.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
#ifdef HAVE_SETRLIMIT
/**
* @var int
* @cvalue RLIM_INFINITY
* @cvalue PHP_POSIX_RLIM_INFINITY
*/
const POSIX_RLIMIT_INFINITY = UNKNOWN;
#endif
Expand Down
4 changes: 2 additions & 2 deletions ext/posix/posix_arginfo.h

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

34 changes: 34 additions & 0 deletions ext/posix/tests/posix_setrlimit_infinity.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
--TEST--
posix_setrlimit() with POSIX_RLIMIT_INFINITY
--EXTENSIONS--
posix
--SKIPIF--
<?php
if (!function_exists('posix_setrlimit')) die('skip posix_setrlimit() not found');
if (posix_getrlimit(POSIX_RLIMIT_CORE)[1] !== 'unlimited') die('skip hard limit of POSIX_RLIMIT_CORE is not unlimited');
?>
--FILE--
<?php

var_dump(posix_setrlimit(POSIX_RLIMIT_CORE, 1024, POSIX_RLIMIT_INFINITY));
var_dump(posix_getrlimit(POSIX_RLIMIT_CORE));

var_dump(posix_setrlimit(POSIX_RLIMIT_CORE, POSIX_RLIMIT_INFINITY, POSIX_RLIMIT_INFINITY));
var_dump(posix_getrlimit(POSIX_RLIMIT_CORE));

?>
--EXPECT--
bool(true)
array(2) {
[0]=>
int(1024)
[1]=>
string(9) "unlimited"
}
bool(true)
array(2) {
[0]=>
string(9) "unlimited"
[1]=>
string(9) "unlimited"
}
Loading