exec仍在等待输出,即使我发送它ti / dev / null

I have my code that looks like this:

 exec('php -f bg_post.php -- '.escapeshellarg($_POST["data"]).' 2> /dev/null &');

Because of bg_post.php being very lengthy, I want it to handle the script in the background and then send the user on their marry way after they submit. Only problem is, despite executing the script with exec, and then sending the output to /dev/null, it still wants to wait for the output. How can I fix this?

You're sending standard error to /dev/null, but not standard output. Change:

2> /dev/null

To:

> /dev/null 2>&1