|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-12-24 03:17 UTC] lameventanas at gmail dot com
Description:
------------
My lighttpd server uses fastcgi to run php code.
The php code starts an external program that happens to be a standalone php script (shebang: #!/usr/bin/php-cgi).
The script hangs when started from a php-fpm process manager, but works fine when started from a php-cgi "process manager".
Just to clarify, the process that hangs is the php-cgi which is interpreting the standalone script. If I replace this with a shellscript, everything works fine.
Test script:
---------------
test.php:
<?
header("Content-type: text/plain");
echo "Starting\n";
system("/var/www/htdocs/script.php");
echo "Finished\n";
?>
script.php:
#!/usr/bin/php-cgi -q
<?
echo "Hello world!\n";
?>
Expected result:
----------------
No hangs.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 06:00:01 2026 UTC |
I found that php-cgi is stuck trying to call accept() on stdin: ... 22730 rt_sigaction(SIGPIPE, {SIG_IGN, [PIPE], SA_RESTART}, {SIG_IGN, [PIPE], SA_RESTART}, 8) = 0 22730 brk(0x882d000) = 0x882d000 22730 gettimeofday({1458204368, 785265}, NULL) = 0 22730 open("/tmp/.ZendSem.FT3dUS", O_RDWR|O_CREAT|O_EXCL, 0600) = 3 22730 fchmod(3, 0666) = 0 22730 fcntl64(3, F_GETFD) = 0 22730 fcntl64(3, F_SETFD, FD_CLOEXEC) = 0 22730 unlink("/tmp/.ZendSem.FT3dUS") = 0 22730 mmap2(NULL, 67108864, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS|0x40000, -1, 0) = -1 ENOMEM (Cannot allocate memory) 22730 mmap2(NULL, 67108864, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANONYMOUS, -1, 0) = 0xae200000 22730 fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0 22730 time(NULL) = 1458204368 22730 fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0 22730 fcntl64(3, F_SETLKW, {type=F_WRLCK, whence=SEEK_SET, start=0, len=1}) = 0 22730 fcntl64(3, F_SETLK, {type=F_UNLCK, whence=SEEK_SET, start=0, len=1}) = 0 22730 brk(0x884e000) = 0x884e000 22730 accept(0, So I changed my test script to: system("/var/www/htdocs/script.php < /dev/null"); and it doesn't hang anymore!