public function run($flags = NULL)
{
foreach ($this->envVars as $name => $value) {
putenv("{$name}={$value}");
}
$this->proc = proc_open($this->interpreter->getCommandLine() . ' -d register_argc_argv=on ' . Helpers::escapeArg($this->file) . ' ' . implode(' ', $this->args), [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, dirname($this->file), NULL, ['bypass_shell' => TRUE]);
foreach (array_keys($this->envVars) as $name) {
putenv($name);
}
list($stdin, $this->stdout, $stderr) = $pipes;
fclose($stdin);
if ($flags & self::RUN_COLLECT_ERRORS) {
$this->stderr = $stderr;
} else {
fclose($stderr);
}
if ($flags & self::RUN_ASYNC) {
stream_set_blocking($this->stdout, 0);
// on Windows does not work with proc_open()
if ($this->stderr) {
stream_set_blocking($this->stderr, 0);
}
} else {
while ($this->isRunning()) {
usleep(self::RUN_USLEEP);
// stream_select() doesn't work with proc_open()
}
}
}