ReactPHP: What is the difference between terminate process and close process?

426 views Asked by At

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?

1

There are 1 answers

0
Maxim Tkach On BEST ANSWER

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()