This commit is contained in:
2021-08-19 19:18:28 +08:00
parent 53b68579af
commit 5a0e147c2b
+31 -31
View File
@@ -45,37 +45,37 @@ abstract class CustomProcess implements \Server\SInterface\CustomProcess
*/ */
public function signListen(Process $process): void public function signListen(Process $process): void
{ {
if (Coroutine::getCid() === -1) { // if (Coroutine::getCid() === -1) {
Process::signal(SIGTERM | SIGKILL, function ($signo) use ($process) { // Process::signal(SIGTERM | SIGKILL, function ($signo) use ($process) {
if ($signo) { // if ($signo) {
$lists = Kiri::app()->getProcess(); // $lists = Kiri::app()->getProcess();
foreach ($lists as $process) { // foreach ($lists as $process) {
$process->exit(0); // $process->exit(0);
} // }
} // }
}); // });
} else { // } else {
Coroutine::create(function () use ($process) { // Coroutine::create(function () use ($process) {
/** @var Coroutine\Socket $message */ // /** @var Coroutine\Socket $message */
$message = $process->exportSocket(); // $message = $process->exportSocket();
if ($message->recv() == 0x03455343213212) { // if ($message->recv() == 0x03455343213212) {
$this->waiteExit($process); // $this->waiteExit($process);
} // }
}); // });
Coroutine::create(function () use ($process) { // Coroutine::create(function () use ($process) {
$data = Coroutine::waitSignal(SIGTERM | SIGKILL, -1); // $data = Coroutine::waitSignal(SIGTERM | SIGKILL, -1);
if ($data) { // if ($data) {
$lists = Kiri::app()->getProcess(); // $lists = Kiri::app()->getProcess();
foreach ($lists as $name => $process) { // foreach ($lists as $name => $process) {
foreach ($process as $item) { // foreach ($process as $item) {
/** @var Coroutine\Socket $export */ // /** @var Coroutine\Socket $export */
$export = $item->exportSocket(); // $export = $item->exportSocket();
$export->send(0x03455343213212); // $export->send(0x03455343213212);
} // }
} // }
} // }
}); // });
} // }
} }