diff --git a/src/Runtime/RuntimeProcess.php b/src/Runtime/RuntimeProcess.php index 5f92c93..0ea59b0 100644 --- a/src/Runtime/RuntimeProcess.php +++ b/src/Runtime/RuntimeProcess.php @@ -6,6 +6,7 @@ use Aternos\Taskmaster\Communication\Socket\SocketPair; use Aternos\Taskmaster\Communication\StdStreams; use Aternos\Taskmaster\TaskmasterOptions; +use RuntimeException; /** * Class RuntimeProcess @@ -46,6 +47,9 @@ public function __construct(TaskmasterOptions $options, string $runtimeClass) 2 => $stdStreams->getStderr(), 3 => $socketPair->getChildSocket()->getStream(), ], $pipes); + if (!$this->process) { + throw new RuntimeException("Could not open process."); + } $socketPair->closeChildSocket(); } @@ -57,6 +61,9 @@ public function __construct(TaskmasterOptions $options, string $runtimeClass) public function stop(): bool { $this->socket->close(); + if (!$this->process) { + return false; + } $result = proc_terminate($this->process); proc_close($this->process); $this->process = null;