I am running a simple PHP script on a CentOS 6.5 with php5.3.3
#!/usr/bin/env php
<?php
echo "hello"."\n";
return 0;
?>
My issue is that if I do ./testscript
, it runs fine, if I do nohup ./testscript &
, it runs fine, if I do ./testscript < /dev/null > /dev/null &
it runs fine (it is the same without the output redirection).
But if I do ./testscript &
, the script is stopped (and there is no output) :
[1]+ Stopped ./testscript
From what I understand, this is because php is expecting some input from STDIN. But the question is why ? As you can see, there is nothing requiring some input in this simple script, and I didn't have this behavior on my php5.4 on Debian. Does this change in behavior comes from php version or OS ? And why is it this way ? Is there a way to change that and to allow me to run script in background without having to add /dev/null as STDIN ?
Thank you !