php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63143 http request never end
Submitted: 2012-09-23 14:59 UTC Modified: 2012-09-25 10:09 UTC
Votes:9
Avg. Score:4.1 ± 0.9
Reproduced:7 of 8 (87.5%)
Same Version:2 (28.6%)
Same OS:0 (0.0%)
From: yubing at baixing dot com Assigned:
Status: Wont fix Package: Built-in web server
PHP Version: 5.4.7 OS: CentOS 6.3 & Mac OSX
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2012-09-23 14:59 UTC] yubing at baixing dot com
Description:
------------
I try to use php built-in to run some shell command like: apachectl restart

But I find that, if i start a new process by using exec()/passthru()/shell_exec() funcion, the http request will never close until I kill the process started in php .

I‘ve already tried to append "> /dev/null 2>&1 &"  to the command (as test1.php below)
or but the command to a shell script (as test2.php and ping.sh below)

but the http request still not close before the process ends.

It's ok to run the same code under Apache or pure php cli.
So I think it should be a bug of the php built-in web server, hope someone can fix it~

Test script:
---------------
test1.php:
  <?php
    exec('ping -c 100 google.com > /dev/null 2>&1 &',$output, $code);
    var_dump($output,$code);
  ?>
--------------------------------------
test2.php:
  <?php
    exec('ping.sh',$output, $code);
    var_dump($output,$code);
  ?>
ping.sh:
  #!/bin/bash
  ping -c 100 google.com > /dev/null 2>&1 &


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-09-23 15:08 UTC] laruence@php.net
sorry, I didn't get your point,  you mean test2.php will never stop while host is 
built-in server?
 [2012-09-23 16:46 UTC] yubing at baixing dot com
the php run to the end successfully (but I'm not sure if it's stoped in the php engine), but the tcp connection for http request will be hanging until the ping cmd under shell ends.

If you can help to do a test using the code I wrote, you may get the problem quikely.

Or if you still can't get the meaning of the bug, I can send the chinese version of description to your weibo private message, nice to see you Laruence :)
 [2012-09-23 17:34 UTC] yubing at baixing dot com
I've find a work round for this situation:
Add an "Content-Length" header, then the browser will close the http connection instead waiting for further content.
 [2012-09-25 10:09 UTC] laruence@php.net
-Status: Open +Status: Wont fix
 [2012-09-25 10:09 UTC] laruence@php.net
the socket is not closed due to the exec, even the script finished

so, IMO, in built-in server side, won't fix. :)

thanks
 [2017-09-17 11:15 UTC] mintystark at gmail dot com
I am also having this problem.
unfortunately, adding "Content-Length" wont allow any output from php.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 23:01:27 2024 UTC