protected function readFrame(): void
    {
        $header = $this->forceRead(8);

        if (\strlen($header) < 8) {
            return;
        }

        $decoded = \unpack('C1type/C3/N1size', $header);
        $output = $this->forceRead($decoded['size']);
        $callbackList = [];

        if (0 === $decoded['type']) {
            $callbackList = $this->onStdinCallables;
        }

        if (1 === $decoded['type']) {
            $callbackList = $this->onStdoutCallables;
        }

        if (2 === $decoded['type']) {
            $callbackList = $this->onStderrCallables;
        }

        foreach ($callbackList as $callback) {
            $callback($output);
        }
    }