Launches a process in the foreground.
public launchProcess ( string $command, array $arguments = [], boolean $killable = true ) : integer | ||
$command | string | The command to execute. |
$arguments | array | Arguments to be quoted and inserted into the command. Each key "key" in the array should correspond to a placeholder "%key%" in the command. |
$killable | boolean | Whether the process can be killed by the user. |
return | integer | The exit status of the process. |
public function testLaunchWithError() { if (!$this->php) { $this->markTestSkipped('The "bash" binary is not available.'); return; } if (!function_exists('proc_open')) { $this->markTestSkipped('The "proc_open" function is not available.'); return; } $status = $this->launcher->launchProcess($this->php . ' -r %command%', array('command' => 'exit(123);')); $this->assertSame(123, $status); }
/** * {@inheritdoc} */ public function handle() { if (!$this->processLauncher->isSupported()) { throw new RuntimeException('The ProcessLauncher must be supported for the man help to run.'); } if (!$this->manBinary) { $this->manBinary = $this->executableFinder->find('man'); } if (!$this->manBinary) { throw new RuntimeException('The "man" binary was not found.'); } return $this->processLauncher->launchProcess(escapeshellcmd($this->manBinary) . ' -l %path%', array('path' => $this->path), false); }
/** * {@inheritdoc} */ public function handle(Args $args, IO $io) { if ($this->processLauncher->isSupported()) { if (!$this->lessBinary) { $this->lessBinary = $this->executableFinder->find('less'); } if ($this->lessBinary) { return $this->processLauncher->launchProcess(escapeshellcmd($this->lessBinary) . ' %path%', array('path' => $this->path), false); } } $io->write(file_get_contents($this->path)); return 0; }