|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76529 php-cgi: -C option ignored
Submitted: 2018-06-25 20:36 UTC Modified: 2018-06-27 20:20 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: shhsu at microsoft dot com Assigned:
Status: Verified Package: *General Issues
PHP Version: 7.2.7 OS: Windows
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
23 - 4 = ?
Subscribe to this entry?

 [2018-06-25 20:36 UTC] shhsu at microsoft dot com

We are trying to benchmark PHP performance under IIS. We noticed that PHP is trying to chdir to script directory and that is causing a lot of contention because it's IO bound.

To workaround this. I tried to pass "-C" option to php-cgi.exe. (Process run as: "php-cgi.exe -C" However, I am still observing chdir taking place.

P.S. I noticed that php_execute_script ( gets executed before zend_first_try ( where the -C option is processed. Not sure if this is by design.

Test script:
Setup PHP for IIS. Add the following configuration 
            <application fullPath="C:\php-7.2.7-nts-Win32-VC15\php-cgi.exe" arguments="-C" maxInstances="10" instanceMaxRequests="10000000" queueLength="10000">
                    <environmentVariable name="PHP_FCGI_MAX_REQUESTS" value="10000000" />
                    <environmentVariable name="PHPRC" value="C:\php-7.2.7-nts-Win32-VC15" />

<location path="" overrideMode="Allow">
            <handlers accessPolicy="Read, Script">
                <add name="PHP-iisfcgi" path="*.php" verb="GET,HEAD,POST" modules="FastCgiModule" scriptProcessor="C:\php-7.2.7-nts-Win32-VC15\php-cgi.exe|-C" resourceType="Either" />

Expected result:
If I execute php-cgi with -C, no chdir to script path should take place

Actual result:
chdir to script path


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-06-27 20:20 UTC]
-Status: Open +Status: Verified
 [2018-06-27 20:20 UTC]
Thanks for the report. You're rigt, -C is only taken in account when php-cgi.exe is run on console, like the most of the options. It seems to be indeed by design, as the surrounding condition is "if (!cgi && !fastcgi) {". This likely to be fixed easily by moving the case a couple of lines above into another switch . It seems to be a crossplatform behavior, not IIS specific.

I'm a bit reluctant on changing this right away, because there might be other implication in performance and compatibility with some legacy PHP code. Right now the 7.3 feature freeze is less than a week away and changing this behavior might have a beyond impact. It would be good to hear more opinions and to consider a fix for the next minor version.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 21 13:03:33 2021 UTC