|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
34 - 21 = ?
Subscribe to this entry?

 [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: Fri Oct 07 06:05:54 2022 UTC