I'm experiencing some trouble with the way I am currently starting a process in php and killing it afterwards.
I have the following (pseudo) methods:
$pid = $this->startPeerflix();
$this->doStuff();
$this->killPeerflix($pid);
In startPeerflix() I am basically using exec() to start peerflix, which is a nodejs application, and send it to the background. As a response I get the PID, which works most of the times but not always. Sometimes I check the running processes and I see that peerflix is still running so something went wrong with killing it.
I append this to the command to send it to the background and to get the PID:
> /dev/null 2>/dev/null & echo $!
However this fails on occasions and I can't seem to kill the process. So what are some other options?
TL;DR In PHP I want to start a nodejs process, send it to the background, do some more stuff in php and kill the process afterwards in such a way that the process is always killed.
Aucun commentaire:
Enregistrer un commentaire