Lines Matching refs:this
150 $this->commandline = $command;
151 $this->cwd = $cwd;
157 … if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
158 $this->cwd = getcwd();
161 $this->setEnv($env);
164 $this->setInput($input);
165 $this->setTimeout($timeout);
166 $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
167 $this->pty = false;
216 if ($this->options['create_new_console'] ?? false) {
217 $this->processPipes->close();
219 $this->stop(0);
225 $this->resetProcessData();
253 $this->start($callback, $env);
255 return $this->wait();
272 if (0 !== $this->run($callback, $env)) {
273 throw new ProcessFailedException($this);
276 return $this;
300 if ($this->isRunning()) {
304 $this->resetProcessData();
305 $this->starttime = $this->lastOutputTime = microtime(true);
306 $this->callback = $this->buildCallback($callback);
307 $this->hasCallback = null !== $callback;
308 $descriptors = $this->getDescriptors();
310 if ($this->env) {
311 …$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->e…
314 …= '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $t…
316 if (\is_array($commandline = $this->commandline)) {
317 $commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
324 $commandline = $this->replacePlaceholders($commandline, $env);
328 $commandline = $this->prepareWindowsCommandLine($commandline, $env);
329 } elseif (!$this->useFileHandles && $this->isSigchildEnabled()) {
349 if (!is_dir($this->cwd)) {
350 … throw new RuntimeException(sprintf('The provided cwd "%s" does not exist.', $this->cwd));
353 …$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $e…
355 if (!\is_resource($this->process)) {
358 $this->status = self::STATUS_STARTED;
361 $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
364 if ($this->tty) {
368 $this->updateStatus(false);
369 $this->checkTimeout();
391 if ($this->isRunning()) {
395 $process = clone $this;
418 $this->requireProcessIsStarted(__FUNCTION__);
420 $this->updateStatus(false);
423 if (!$this->processPipes->haveReadSupport()) {
424 $this->stop(0);
427 $this->callback = $this->buildCallback($callback);
431 $this->checkTimeout();
432 …$running = $this->isRunning() && ('\\' === \DIRECTORY_SEPARATOR || $this->processPipes->areOpen());
433 $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
436 while ($this->isRunning()) {
437 $this->checkTimeout();
441 …if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->lates…
442 throw new ProcessSignaledException($this);
445 return $this->exitcode;
461 $this->requireProcessIsStarted(__FUNCTION__);
462 $this->updateStatus(false);
464 if (!$this->processPipes->haveReadSupport()) {
465 $this->stop(0);
468 $callback = $this->buildCallback($callback);
472 $this->checkTimeout();
473 … $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
474 … $output = $this->processPipes->readAndWrite($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
479 } elseif (!isset($this->fallbackStatus['signaled'])) {
480 $this->fallbackStatus['exitcode'] = (int) $data;
501 return $this->isRunning() ? $this->processInformation['pid'] : null;
517 $this->doSignal($signal, true);
519 return $this;
532 if ($this->isRunning()) {
535 if (null !== $this->idleTimeout) {
539 $this->outputDisabled = true;
541 return $this;
553 if ($this->isRunning()) {
557 $this->outputDisabled = false;
559 return $this;
569 return $this->outputDisabled;
582 $this->readPipesForOutput(__FUNCTION__);
584 if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
604 $this->readPipesForOutput(__FUNCTION__);
606 $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
607 $this->incrementalOutputOffset = ftell($this->stdout);
629 $this->readPipesForOutput(__FUNCTION__, false);
636 …while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($thi…
638 $out = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
642 $this->clearOutput();
644 $this->incrementalOutputOffset = ftell($this->stdout);
652 $err = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
656 $this->clearErrorOutput();
658 $this->incrementalErrorOutputOffset = ftell($this->stderr);
669 $this->checkTimeout();
670 $this->readPipesForOutput(__FUNCTION__, $blocking);
681 ftruncate($this->stdout, 0);
682 fseek($this->stdout, 0);
683 $this->incrementalOutputOffset = 0;
685 return $this;
698 $this->readPipesForOutput(__FUNCTION__);
700 if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
721 $this->readPipesForOutput(__FUNCTION__);
723 $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
724 $this->incrementalErrorOutputOffset = ftell($this->stderr);
740 ftruncate($this->stderr, 0);
741 fseek($this->stderr, 0);
742 $this->incrementalErrorOutputOffset = 0;
744 return $this;
754 $this->updateStatus(false);
756 return $this->exitcode;
772 if (null === $exitcode = $this->getExitCode()) {
786 return 0 === $this->getExitCode();
800 $this->requireProcessIsTerminated(__FUNCTION__);
802 return $this->processInformation['signaled'];
817 $this->requireProcessIsTerminated(__FUNCTION__);
819 if ($this->isSigchildEnabled() && -1 === $this->processInformation['termsig']) {
823 return $this->processInformation['termsig'];
837 $this->requireProcessIsTerminated(__FUNCTION__);
839 return $this->processInformation['stopped'];
853 $this->requireProcessIsTerminated(__FUNCTION__);
855 return $this->processInformation['stopsig'];
865 if (self::STATUS_STARTED !== $this->status) {
869 $this->updateStatus(false);
871 return $this->processInformation['running'];
881 return self::STATUS_READY != $this->status;
891 $this->updateStatus(false);
893 return self::STATUS_TERMINATED == $this->status;
905 $this->updateStatus(false);
907 return $this->status;
921 if ($this->isRunning()) {
923 $this->doSignal(15, false);
926 } while ($this->isRunning() && microtime(true) < $timeoutMicro);
928 if ($this->isRunning()) {
931 $this->doSignal($signal ?: 9, false);
935 if ($this->isRunning()) {
936 if (isset($this->fallbackStatus['pid'])) {
937 unset($this->fallbackStatus['pid']);
939 return $this->stop(0, $signal);
941 $this->close();
944 return $this->exitcode;
954 $this->lastOutputTime = microtime(true);
956 fseek($this->stdout, 0, \SEEK_END);
957 fwrite($this->stdout, $line);
958 fseek($this->stdout, $this->incrementalOutputOffset);
968 $this->lastOutputTime = microtime(true);
970 fseek($this->stderr, 0, \SEEK_END);
971 fwrite($this->stderr, $line);
972 fseek($this->stderr, $this->incrementalErrorOutputOffset);
980 return $this->lastOutputTime;
990 …return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->co…
1000 return $this->timeout;
1010 return $this->idleTimeout;
1024 $this->timeout = $this->validateTimeout($timeout);
1026 return $this;
1041 if (null !== $timeout && $this->outputDisabled) {
1045 $this->idleTimeout = $this->validateTimeout($timeout);
1047 return $this;
1067 $this->tty = $tty;
1069 return $this;
1079 return $this->tty;
1089 $this->pty = $bool;
1091 return $this;
1101 return $this->pty;
1111 if (null === $this->cwd) {
1117 return $this->cwd;
1127 $this->cwd = $cwd;
1129 return $this;
1139 return $this->env;
1151 $this->env = $env;
1153 return $this;
1163 return $this->input;
1179 if ($this->isRunning()) {
1183 $this->input = ProcessUtils::validateInput(__METHOD__, $input);
1185 return $this;
1198 if (self::STATUS_STARTED !== $this->status) {
1202 if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
1203 $this->stop(0);
1205 throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
1208 … if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
1209 $this->stop(0);
1211 throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
1220 if (!$this->isStarted()) {
1224 return $this->starttime;
1237 if ($this->isRunning()) {
1241 $defaultOptions = $this->options;
1246 $this->options = $defaultOptions;
1249 $this->options[$key] = $value;
1292 if ($this->input instanceof \Iterator) {
1293 $this->input->rewind();
1296 …$this->processPipes = new WindowsPipes($this->input, !$this->outputDisabled || $this->hasCallback);
1298 …$this->processPipes = new UnixPipes($this->isTty(), $this->isPty(), $this->input, !$this->outputDi…
1301 return $this->processPipes->getDescriptors();
1316 if ($this->outputDisabled) {
1326 $this->addOutput($data);
1328 $this->addErrorOutput($data);
1342 if (self::STATUS_STARTED !== $this->status) {
1346 $this->processInformation = proc_get_status($this->process);
1347 $running = $this->processInformation['running'];
1353 … if (!isset($this->cachedExitCode) && !$running && -1 !== $this->processInformation['exitcode']) {
1354 $this->cachedExitCode = $this->processInformation['exitcode'];
1357 … if (isset($this->cachedExitCode) && !$running && -1 === $this->processInformation['exitcode']) {
1358 $this->processInformation['exitcode'] = $this->cachedExitCode;
1362 $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
1364 if ($this->fallbackStatus && $this->isSigchildEnabled()) {
1365 $this->processInformation = $this->fallbackStatus + $this->processInformation;
1369 $this->close();
1404 if ($this->outputDisabled) {
1408 $this->requireProcessIsStarted($caller);
1410 $this->updateStatus($blocking);
1439 $result = $this->processPipes->readAndWrite($blocking, $close);
1441 $callback = $this->callback;
1445 } elseif (!isset($this->fallbackStatus['signaled'])) {
1446 $this->fallbackStatus['exitcode'] = (int) $data;
1458 $this->processPipes->close();
1459 if (\is_resource($this->process)) {
1460 proc_close($this->process);
1462 $this->exitcode = $this->processInformation['exitcode'];
1463 $this->status = self::STATUS_TERMINATED;
1465 if (-1 === $this->exitcode) {
1466 if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
1468 $this->exitcode = 128 + $this->processInformation['termsig'];
1469 } elseif ($this->isSigchildEnabled()) {
1470 $this->processInformation['signaled'] = true;
1471 $this->processInformation['termsig'] = -1;
1478 $this->callback = null;
1480 return $this->exitcode;
1488 $this->starttime = null;
1489 $this->callback = null;
1490 $this->exitcode = null;
1491 $this->fallbackStatus = [];
1492 $this->processInformation = null;
1493 $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
1494 $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+');
1495 $this->process = null;
1496 $this->latestSignal = null;
1497 $this->status = self::STATUS_READY;
1498 $this->incrementalOutputOffset = 0;
1499 $this->incrementalErrorOutputOffset = 0;
1514 if (null === $pid = $this->getPid()) {
1524 if ($exitCode && $this->isRunning()) {
1532 if (!$this->isSigchildEnabled()) {
1533 $ok = @proc_terminate($this->process, $signal);
1548 $this->latestSignal = $signal;
1549 $this->fallbackStatus['signaled'] = true;
1550 $this->fallbackStatus['exitcode'] = -1;
1551 $this->fallbackStatus['termsig'] = $this->latestSignal;
1595 foreach ($this->processPipes->getFiles() as $offset => $filename) {
1609 if (!$this->isStarted()) {
1621 if (!$this->isTerminated()) {
1655 return $this->escapeArgument($env[$matches[1]]);