code: 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;
      }
docs: Register given callable with pcntl signal.
  
  @param int $signal The pcntl signal.
  @param callback $handler The signal handler.
  
  @return $this
  @throws \RuntimeException If could not register handler with pcntl_signal.