bin = $bin; $this->stub = $stub; } public function scan(): Scanned { if (env(static::SCAN_PROC_WORKER)) { return new Scanned(false); } $proc = proc_open( [$this->bin, $this->stub], [0 => STDIN, 1 => ['pipe', 'w'], 2 => ['redirect', 1]], $pipes, null, [static::SCAN_PROC_WORKER => '(true)'] ); $output = ''; do { $output .= fread($pipes[1], 8192); } while (! feof($pipes[1])); if (proc_close($proc) !== 0) { echo $output; exit(-1); } return new Scanned(true); } }