enable_queue; } /** * @return string */ public function getName(): string { if (empty($this->name)) { $this->name = uniqid('p.'); } return $this->name; } /** * @return bool */ public function isStop(): bool { return $this->stop; } /** * @return bool */ public function getRedirectStdinAndStdout(): bool { return $this->redirect_stdin_and_stdout; } /** * @return int */ public function getPipeType(): int { return $this->pipe_type; } /** * @return bool */ public function isEnableCoroutine(): bool { return $this->enable_coroutine; } /** * */ public function stop(): void { $this->stop = true; } /** * @return void */ abstract public function onSigterm(): void; /** * @param Process $process * @return AbstractProcess */ public function onShutdown(Process $process): static { $this->process = $process; if ($this->enable_coroutine) { Coroutine::create(fn () => $this->coroutineWaitSignal()); } else { pcntl_signal(SIGTERM, [$this, 'pointWaitSignal']); } return $this; } /** * @param $data * @return void */ public function pointWaitSignal($data): void { $this->stop = true; $this->onSigterm(); } /** * @return void */ public function coroutineWaitSignal(): void { $value = Coroutine::waitSignal(SIGTERM); if ($value) { $this->stop = true; } $this->onSigterm(); } }