|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #48506 upcoming apr closes descriptors by default
Submitted: 2009-06-09 13:47 UTC Modified: 2020-11-15 04:22 UTC
From: arekm at maven dot pl Assigned: cmb (profile)
Status: No Feedback Package: Apache2 related
PHP Version: 5.2.9 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: arekm at maven dot pl
New email:
PHP Version: OS:


 [2009-06-09 13:47 UTC] arekm at maven dot pl
Upcoming apr 2.0.0 (or 1.3 with backported patch) uses O_CLOEXEC for own descriptors by default.

This means that when using shell_exec() the run script/binary has no stdin/stdout/stderr due to O_CLOEXEC. This also means that if any output is produced then script ends with EPIPE.

Tested with apache + apr 1.3 with backported patch.

Reproduce code:
echo shell_exec("LC_ALL=C strace -o /tmp/WYNIK -f -F -s 200 ls -l /notexistingfile");

Run from apache + php + apr 1.3 + backported O_CLOEXEC patch like this one

Expected result:
run "ls -l" and produce some output about file not existing

Actual result:
30120 lstat("/notexistingfile", 0x18f55f0) = -1 ENOENT (No such file or directory)
30120 write(2, "ls: ", 4)               = -1 EBADF (Bad file descriptor)
30120 write(2, "cannot access /notexistingfile", 30) = -1 EBADF (Bad file descriptor)
30120 write(2, ": No such file or directory", 27) = -1 EBADF (Bad file descriptor)
30120 write(2, "\n", 1)                 = -1 EBADF (Bad file descriptor)
30120 close(1)                          = 0
30120 close(2)                          = -1 EBADF (Bad file descriptor)
30120 exit_group(2)

As you can see there is no file descriptor 2 and this means that ls output is lost.

Probably the best for php is to always provide own descriptors without relying on apache provided one.           


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-07-25 15:01 UTC] arekm at maven dot pl
Note that latest released stable apr 1.3.6 also contains these changes and distributions will start to pick up these soon.)
 [2010-12-20 14:28 UTC]
-Package: Feature/Change Request +Package: Apache2 related
 [2017-10-24 06:12 UTC]
-Status: Assigned +Status: Open -Assigned To: scottmac +Assigned To:
 [2020-11-05 13:49 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2020-11-05 13:49 UTC]
I assume that this has already been catered to, hasn't it?
 [2020-11-15 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sat Nov 28 01:01:23 2020 UTC