I am testing a php script that has been developed on an OS-X system at Debian and it behaves different there.
To reproduce it I wrote two scripts: parent.php and child.php:
parent.php:
#!/usr/bin/php
<?php
echo "parent started...\n";
shell_exec(__DIR__ . '/child.php &2>/dev/null &');
echo "parent finished.\n";
child.php:
#!/usr/bin/php
<?php
echo "child started...\n";
sleep(5);
echo "child finished.\n";
Running parent.php on OS-X I get back imediately the two output lines (parent started, parent finished). On Debian I get the "parent started..." line, then a delay of 5 seconds an then the "parent finished.". Running "./child.php &2>/dev/null &" in the shell gives me back the prompt imediately as expected. Any ideas how I can fix this?
{cmd} > /dev/null 2>&1 &- would be interested to know if that makes a difference.&2>/dev/nullor just want to suppress any output?