1
0
Fork 0

Make sure async processes fail the promise if they fail to start, fixes #9808

pull/9900/head
Jordi Boggiano 2021-05-20 14:15:14 +02:00
parent 8427b6c8ed
commit 251b852fd2
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
1 changed files with 22 additions and 6 deletions

View File

@ -250,16 +250,32 @@ class ProcessExecutor
throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd); throw new \RuntimeException('The given CWD for the process does not exist: '.$cwd);
} }
// TODO in v3, commands should be passed in as arrays of cmd + args try {
if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { // TODO in v3, commands should be passed in as arrays of cmd + args
$process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout()); if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
} else { $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
$process = new Process($command, $cwd, null, null, static::getTimeout()); } else {
$process = new Process($command, $cwd, null, null, static::getTimeout());
}
} catch (\Exception $e) {
call_user_func($job['reject'], $e);
return;
} catch (\Throwable $e) {
call_user_func($job['reject'], $e);
return;
} }
$job['process'] = $process; $job['process'] = $process;
$process->start(); try {
$process->start();
} catch (\Exception $e) {
call_user_func($job['reject'], $e);
return;
} catch (\Throwable $e) {
call_user_func($job['reject'], $e);
return;
}
} }
public function wait($index = null) public function wait($index = null)