I am calling some bash code from php, but even though I fork the bash (with &), the php will not finish before the full bash is done.
This code:
<html>
<body>
HTML START<br>
<pre>
<?php
echo "PHP START\n";
echo `sleep 30 &`;
echo "PHP END\n";
?>
</pre>
HTML END<br>
</body>
</html>
Will not show anything in the browser, before after 30 seconds.
What I really want is to start a GUI app from php, that should continue to run.
Close all file descriptors in your sleep call to allow it to detach:
Otherwise, the output file descriptor is still open, and PHP is still trying to wait to receive its output, even with the process no longer attached directly.
This works correctly when run, immediately exiting but leaving a sleep process behind: