Req #36868 [Opn->Nab]: fopen does not set errno for posix_get_last_error
| From: | heiglandreas@php.net | Date: | Fri, 20 Jan 2017 20:50:14 +0000 |
| Subject: | Req #36868 [Opn->Nab]: fopen does not set errno for posix_get_last_error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206793@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=36868&edit=1
ID: 36868
Updated by: heiglandreas@php.net
Reported by: dgatwood at mac dot com
Summary: fopen does not set errno for posix_get_last_error
-Status: Open
+Status: Not a bug
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Mac OS X
PHP Version: 5.1.2
Block user comment: N
Private report: N
New Comment:
posix_get_last_error â Retrieve the error number set by the last posix function that failed -
fopen is not part of the posix-extension. So this is not a bug.
Previous Comments:
------------------------------------------------------------------------
[2006-03-27 06:25:53] dgatwood at mac dot com
Description:
------------
On Mac OS X, when fopen() fails with a permission denied
error, the result of a subsequent posix_get_last_error()
call is zero (0). I would expect this to be set to the
value of errno returned by the underlying open or fopen
call.
I would also expect this to work for put_file_contents, but
also get a rather useless zero when calling
posix_get_last_error() after that fails. However, since
that isn't a POSIX function, I can accept that it wouldn't
behave in this way... but fopen is a standard POSIX
function, and should be setting errno.
Currently, it appears that without explicitly doing a stat
on the directory, it is impossible to distinguish a
permissions problem from some other error return (e.g. file
exists, I/O error, etc.).
Reproduce code:
---------------
$fp = fopen("/unwritabledirectory/filename", "w");
if (!$fp) {
print "Error was: ".posix_get_last_error().".\n";
}
Expected result:
----------------
I would expect the fopen to fail with a permission denied
error, errno to be set appropriately, and posix_get_last_error
() to fetch that value.
Actual result:
--------------
Error is always zero (0).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=36868&edit=1