From ca094df37e717e1b90867fd5c08d0d60b94be2ac Mon Sep 17 00:00:00 2001 From: Joop Schilder Date: Wed, 16 Jan 2019 17:24:06 +0100 Subject: [PATCH] Added signal handler --- src/Asynchronous.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Asynchronous.php b/src/Asynchronous.php index 096bb9a..6d1957d 100644 --- a/src/Asynchronous.php +++ b/src/Asynchronous.php @@ -235,6 +235,18 @@ class Asynchronous self::removedShmBlock(); }); + /* + * The signal handler + */ + foreach([SIGINT, SIGTERM, SIGUSR1] as $signal) + pcntl_signal($signal, function($s) use (&$instance) { + if ($instance->isChild) + return; + self::killChildren(); + self::awaitChildren(); + self::removedShmBlock(); + }); + } } \ No newline at end of file