I'm trying to run my server from PHP script as a background process, but it's hanging the PHP script anyway. I call it like this:
$exec_result = exec('./myapp option1 option2 &> /dev/null &');
I tried things from PHP hanging while exec() bash script like adding "set -m && " or "shopt -u checkjobs && " but that doesn't help. I also tried to call in exec() my C++ utility that runs command in background (basically just calls std::system with " &"), but that didn't help either. Using "nohup" doesn't change anything. Also, the problem is not in my server because same thing happens when I call "sleep" command.
Calling exactly the same command from bash runs process in background as expected. Honestly I'm so confused and frustrated. What am I doing wrong? Maybe PHP needs some kind of permissions to run a background task? I'm kinda new to Linux.
I'm doing it all from Debian 10 and PHP 7.3 if it matters.