Using the reactphp/child-process library,
$loop = React\EventLoop\Factory::create();
$process = new React\ChildProcess\Process(...some long proccess..);
$process->on('exit', function($exitCode, $termSignal) {
// ...
});
$process->start($loop);
$loop->run();
to kill the process should I use $process->close()
or $process->terminate()
?
Whats the difference?
terminate() - This method call proc_terminate method, and you can send custom signal. By default proc_terminate send SIGTERM, but you can send another signal, for example SIGSTOP or SIGKILL
close() - This method close descriptors and call proc_close. $this->process set null, and write exit code in $this->exitCode
If you need stop child process - call close()