public function kill()
{
if ($this->isRunning()) {
// Forcefully kill the process using SIGKILL.
posix_kill($this->pid, SIGKILL);
}
if (null !== $this->pipe && $this->pipe->isOpen()) {
$this->pipe->close();
}
// "Detach" from the process and let it die asynchronously.
$this->pid = 0;
$this->channel = null;
}