public function registerHandler($signal, $handler)
    {
        if (!is_callable($handler)) {
            throw new \InvalidArgumentException('The handler is not callable');
        }

        if (!isset($this->handlers[$signal])) {
            $this->handlers[$signal] = [];

            if (!pcntl_signal($signal, [$this, 'handleSignal'])) {
                throw new \RuntimeException(sprintf('Could not register signal %d with pcntl_signal', $signal));
            };
        };

        $this->handlers[$signal][] = $handler;
        return $this;
    }