Perl exec('/usr/bin/php -v') hangs on CentOS 6.6 unless STDIN is closed first Perl exec('/usr/bin/php -v') hangs on CentOS 6.6 unless STDIN is closed first php php

Perl exec('/usr/bin/php -v') hangs on CentOS 6.6 unless STDIN is closed first


I just tested this on Ubuntu 14.04 and RHEL 6.7, and could not reproduce the problem.

I suspect there is a bug that is causing it to both print the version and attempt to process STDIN as PHP code. While it's hanging, try pressing Control-D, or typing a few lines of HTML/PHP and then pressing Control-D to see if your input is processed.


I have a CentOS with the same issue, resolved by adding an ampersand(&) at the end of the system call while you can keep yum.

I actually use a python script to call the php, same issue.

The real issue - unknown, if anyone have some idea, please let me know as well.

Solution:

exec("/usr/bin/php -v &");`/usr/bin/php -q ./mini.php &`;

my os:

CentOS release 6.4 (Final)CentOS release 6.4 (Final)[gliang@www perl_tools]$ perl -vThis is perl, v5.10.1 (*) built for x86_64-linux-thread-multi[gliang@www perl_tools]$ php -vPHP 5.3.3 (cli) (built: Jul  9 2015 17:39:00)Copyright (c) 1997-2010 The PHP GroupZend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologieswith Xdebug v2.1.4, Copyright (c) 2002-2012, by Derick Rethans[gliang@www perl_tools]$

Issue duplicated:

[gliang@www perl_tools]$ perl mini.pl &[1] 29744[gliang@www perl_tools]$ ps uax|grep phpgliang   29744  0.1  0.3 341016  8728 pts/0    T    20:27   0:00    /usr/bin/php -vgliang   29756  0.0  0.0 103248   812 pts/0    S+   20:27   0:00 grep php[1]+  Stopped                 perl mini.pl[gliang@www perl_tools]$