|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #49396 Need access to system errno
Submitted: 2009-08-28 07:56 UTC Modified: 2021-01-06 15:17 UTC
Avg. Score:4.8 ± 0.6
Reproduced:11 of 11 (100.0%)
Same Version:7 (63.6%)
Same OS:9 (81.8%)
From: phpbugs at jan-o-sch dot net Assigned:
Status: Suspended Package: *General Issues
PHP Version: * OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2009-08-28 07:56 UTC] phpbugs at jan-o-sch dot net
All system level php functions only return boolean values, which makes generic error handling easy. However, for a more sophisticated error handling, access to errno is required.

For example: I try to touch() a file and touch() returns false. The only hint I can get is using an error handler or calling error_get_last(), none of which provides me with an errno value. Yes, I do want to react differently to EPERM and EDQUOT. No, I do not want to parse "touch(): Unable to create file /fail because Permission denied".

Alternatively, having posix_* versions of all system functions would allow one to use posix_get_last_error().


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 13:16 UTC]
-Package: Feature/Change Request +Package: *General Issues -Operating System: Linux / Solaris +Operating System: * -PHP Version: 5.2.10 +PHP Version: *
 [2013-07-23 14:14 UTC] Laurent dot Lyaudet at gmail dot com

I want to add up to this feature/change request.
In particular for ftp functions.

Here is my report and a test script.

I did a few tests with ftp functions:
it would be better for ftp_nlist to return error codes.
Right now the situation is the following :
- with an invalid resource (ftp_nlist(0,'.') for example), it will return NULL
- if you're not loggued in, it will return false
- if you're loggued in, it will return an array
- if you kill the connexion on the server, it will return false
BUT you will not be able to log in again with the same resource.
You have to close the connexion and create a new one with connect.
Moreover, you somehow have two kinds of invalid resources:
- arbitrary doubles,
- killed connexions.

Best regards,
  Laurent Lyaudet

vm3:~# php
$con = ftp_connect(@myIP@);
ftp_login($con, @myLogin@, @myPassword@);
sleep(11); //kill the ftp process on the server
$test = ftp_login($con, @myLogin@, @myPassword@);
$res = ftp_nlist($con,'./test');
 [2013-07-23 14:42 UTC] Laurent dot Lyaudet at gmail dot com
While touch is a user level function as are the ftp functions, I still think a better error handling is needed.
 [2021-01-06 15:17 UTC]
-Status: Open +Status: Suspended
 [2021-01-06 15:17 UTC]
As of PHP 7.4.0, you could use the FFI extension to access errno.
However, I would not recommend doing so.  The proper way forward
might indeed be some PHP internal improvements, but these would
need to be discussed on the internals mailing list, and might
require the RFC process[1].  So if you're still interested in
this, please start that process.  For the time being, I'm
suspending this ticket.

[1] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 15 20:01:39 2024 UTC