|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28996 fsockopen(unix_socket) and file descriptors leaking
Submitted: 2004-07-02 18:30 UTC Modified: 2004-07-02 19:27 UTC
From: b dot mourgues at newtech dot fr Assigned:
Status: Closed Package: Sockets related
PHP Version: 4CVS-2004-07-02 (stable) OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: b dot mourgues at newtech dot fr
New email:
PHP Version: OS:


 [2004-07-02 18:30 UTC] b dot mourgues at newtech dot fr
When using fsockopen with non "available" unix socket, fsockopen returns FALSE (no file descriptor), but an unix socket remains opened in webserver process running php.

watch -n 1 'lsof -U | grep ^apache | wc -l'

while opening the following page (replacing "apache" by the real name of your webserver).

Suggestion : in file main/network.c, in function _php_stream_sock_open_unix, when php_connect_nonb fails, closesocket(socketd) should be invoked before returning NULL.

Reproduce code:
        $PHPfd = fsockopen("/dev/null", 0, $PHPerrno, $PHPerrstr);

PID : <?php print getmypid() . " ".  $PHPerrstr . "."; ?>

Expected result:
When fsockopen returns FALSE, no file descriptor created by this function should remain opened


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-07-02 19:27 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

The next snapshot from will contain the fix.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Sep 29 15:03:44 2022 UTC