Edit report at https://bugs.php.net/bug.php?id=63143&edit=1
ID: 63143 Updated by: [email protected] Reported by: yubing at baixing dot com Summary: http request never end -Status: Open +Status: Wont fix Type: Bug Package: Built-in web server Operating System: CentOS 6.3 & Mac OSX PHP Version: 5.4.7 Block user comment: N Private report: N New Comment: the socket is not closed due to the exec, even the script finished so, IMO, in built-in server side, won't fix. :) thanks Previous Comments: ------------------------------------------------------------------------ [2012-09-23 17:34:31] 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-23 16:46:02] 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 15:08:10] [email protected] sorry, I didn't get your point, you mean test2.php will never stop while host is built-in server? ------------------------------------------------------------------------ [2012-09-23 14:59:40] 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 & ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63143&edit=1
