mirror of
https://github.com/php/php-src.git
synced 2024-11-23 09:54:15 +08:00
ext/posix: posix_isatty set errno for it too.
Close GH-13918
This commit is contained in:
parent
2079da0158
commit
db2869346c
2
NEWS
2
NEWS
@ -173,6 +173,8 @@ PHP NEWS
|
||||
|
||||
- POSIX:
|
||||
. Added POSIX_SC_CHILD_MAX and POSIX_SC_CLK_TCK constants. (Jakub Zelenka)
|
||||
. Updated posix_isatty to set the error number on file descriptors.
|
||||
(David Carlier)
|
||||
|
||||
- PSpell:
|
||||
. Moved to PECL. (Derick Rethans)
|
||||
|
@ -383,6 +383,10 @@ PHP 8.4 UPGRADE NOTES
|
||||
- PGSQL:
|
||||
. pg_select, the conditions arguments accepts an empty array and is optional.
|
||||
|
||||
- POSIX:
|
||||
. posix_isatty now sets the error number when the file descriptor/stream argument
|
||||
is invalid.
|
||||
|
||||
- SPL:
|
||||
. SplPriorityQueue::insert() and SplPriorityQueue::recoverFromCorruption()
|
||||
now has a tentative return type of true
|
||||
|
@ -521,11 +521,13 @@ PHP_FUNCTION(posix_isatty)
|
||||
|
||||
/* A valid file descriptor must fit in an int and be positive */
|
||||
if (fd < 0 || fd > INT_MAX) {
|
||||
POSIX_G(last_error) = EBADF;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
if (isatty(fd)) {
|
||||
RETURN_TRUE;
|
||||
} else {
|
||||
POSIX_G(last_error) = errno;
|
||||
RETURN_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -11,13 +11,19 @@ if (PHP_INT_SIZE != 8) die('skip C int is same size as zend_long');
|
||||
|
||||
$values = [
|
||||
-1,
|
||||
10024,
|
||||
2**50+1,
|
||||
];
|
||||
|
||||
foreach ($values as $value) {
|
||||
var_dump(posix_isatty($value));
|
||||
var_dump(posix_strerror(posix_get_last_error()));
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
||||
string(19) "Bad file descriptor"
|
||||
bool(false)
|
||||
string(19) "Bad file descriptor"
|
||||
bool(false)
|
||||
string(19) "Bad file descriptor"
|
||||
|
Loading…
Reference in New Issue
Block a user