Close all file descriptors during a sleep call so that it can disconnect:
<?php echo "PHP START\n"; echo `sleep 30 <&- 1<&- 2<&- &`; echo "PHP END\n"; ?>
Otherwise, the output file descriptor is still open, and PHP is still trying to wait to receive its output, even if the process is no longer directly bound.
This works correctly at startup, leaving the system immediately, but leaving the sleep process behind:
$ time php5 test.php; ps auxw | grep sleep | grep -v grep PHP START PHP END real 0m0.019s user 0m0.008s sys 0m0.004s cduffy 6239 0.0 0.0 11240 576 pts/0 S 11:23 0:00 sleep 30
source share