Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/process
File: Process.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/*
[2] Fix | Delete
* This file is part of the Symfony package.
[3] Fix | Delete
*
[4] Fix | Delete
* (c) Fabien Potencier <fabien@symfony.com>
[5] Fix | Delete
*
[6] Fix | Delete
* For the full copyright and license information, please view the LICENSE
[7] Fix | Delete
* file that was distributed with this source code.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
namespace Symfony\Component\Process;
[11] Fix | Delete
[12] Fix | Delete
use Symfony\Component\Process\Exception\InvalidArgumentException;
[13] Fix | Delete
use Symfony\Component\Process\Exception\LogicException;
[14] Fix | Delete
use Symfony\Component\Process\Exception\ProcessFailedException;
[15] Fix | Delete
use Symfony\Component\Process\Exception\ProcessTimedOutException;
[16] Fix | Delete
use Symfony\Component\Process\Exception\RuntimeException;
[17] Fix | Delete
use Symfony\Component\Process\Pipes\PipesInterface;
[18] Fix | Delete
use Symfony\Component\Process\Pipes\UnixPipes;
[19] Fix | Delete
use Symfony\Component\Process\Pipes\WindowsPipes;
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Process is a thin wrapper around proc_* functions to easily
[23] Fix | Delete
* start independent PHP processes.
[24] Fix | Delete
*
[25] Fix | Delete
* @author Fabien Potencier <fabien@symfony.com>
[26] Fix | Delete
* @author Romain Neutron <imprec@gmail.com>
[27] Fix | Delete
*/
[28] Fix | Delete
class Process implements \IteratorAggregate
[29] Fix | Delete
{
[30] Fix | Delete
const ERR = 'err';
[31] Fix | Delete
const OUT = 'out';
[32] Fix | Delete
[33] Fix | Delete
const STATUS_READY = 'ready';
[34] Fix | Delete
const STATUS_STARTED = 'started';
[35] Fix | Delete
const STATUS_TERMINATED = 'terminated';
[36] Fix | Delete
[37] Fix | Delete
const STDIN = 0;
[38] Fix | Delete
const STDOUT = 1;
[39] Fix | Delete
const STDERR = 2;
[40] Fix | Delete
[41] Fix | Delete
// Timeout Precision in seconds.
[42] Fix | Delete
const TIMEOUT_PRECISION = 0.2;
[43] Fix | Delete
[44] Fix | Delete
const ITER_NON_BLOCKING = 1; // By default, iterating over outputs is a blocking call, use this flag to make it non-blocking
[45] Fix | Delete
const ITER_KEEP_OUTPUT = 2; // By default, outputs are cleared while iterating, use this flag to keep them in memory
[46] Fix | Delete
const ITER_SKIP_OUT = 4; // Use this flag to skip STDOUT while iterating
[47] Fix | Delete
const ITER_SKIP_ERR = 8; // Use this flag to skip STDERR while iterating
[48] Fix | Delete
[49] Fix | Delete
private $callback;
[50] Fix | Delete
private $hasCallback = false;
[51] Fix | Delete
private $commandline;
[52] Fix | Delete
private $cwd;
[53] Fix | Delete
private $env;
[54] Fix | Delete
private $input;
[55] Fix | Delete
private $starttime;
[56] Fix | Delete
private $lastOutputTime;
[57] Fix | Delete
private $timeout;
[58] Fix | Delete
private $idleTimeout;
[59] Fix | Delete
private $options = ['suppress_errors' => true];
[60] Fix | Delete
private $exitcode;
[61] Fix | Delete
private $fallbackStatus = [];
[62] Fix | Delete
private $processInformation;
[63] Fix | Delete
private $outputDisabled = false;
[64] Fix | Delete
private $stdout;
[65] Fix | Delete
private $stderr;
[66] Fix | Delete
private $enhanceWindowsCompatibility = true;
[67] Fix | Delete
private $enhanceSigchildCompatibility;
[68] Fix | Delete
private $process;
[69] Fix | Delete
private $status = self::STATUS_READY;
[70] Fix | Delete
private $incrementalOutputOffset = 0;
[71] Fix | Delete
private $incrementalErrorOutputOffset = 0;
[72] Fix | Delete
private $tty = false;
[73] Fix | Delete
private $pty;
[74] Fix | Delete
private $inheritEnv = false;
[75] Fix | Delete
[76] Fix | Delete
private $useFileHandles = false;
[77] Fix | Delete
/** @var PipesInterface */
[78] Fix | Delete
private $processPipes;
[79] Fix | Delete
[80] Fix | Delete
private $latestSignal;
[81] Fix | Delete
[82] Fix | Delete
private static $sigchild;
[83] Fix | Delete
[84] Fix | Delete
/**
[85] Fix | Delete
* Exit codes translation table.
[86] Fix | Delete
*
[87] Fix | Delete
* User-defined errors must use exit codes in the 64-113 range.
[88] Fix | Delete
*/
[89] Fix | Delete
public static $exitCodes = [
[90] Fix | Delete
0 => 'OK',
[91] Fix | Delete
1 => 'General error',
[92] Fix | Delete
2 => 'Misuse of shell builtins',
[93] Fix | Delete
[94] Fix | Delete
126 => 'Invoked command cannot execute',
[95] Fix | Delete
127 => 'Command not found',
[96] Fix | Delete
128 => 'Invalid exit argument',
[97] Fix | Delete
[98] Fix | Delete
// signals
[99] Fix | Delete
129 => 'Hangup',
[100] Fix | Delete
130 => 'Interrupt',
[101] Fix | Delete
131 => 'Quit and dump core',
[102] Fix | Delete
132 => 'Illegal instruction',
[103] Fix | Delete
133 => 'Trace/breakpoint trap',
[104] Fix | Delete
134 => 'Process aborted',
[105] Fix | Delete
135 => 'Bus error: "access to undefined portion of memory object"',
[106] Fix | Delete
136 => 'Floating point exception: "erroneous arithmetic operation"',
[107] Fix | Delete
137 => 'Kill (terminate immediately)',
[108] Fix | Delete
138 => 'User-defined 1',
[109] Fix | Delete
139 => 'Segmentation violation',
[110] Fix | Delete
140 => 'User-defined 2',
[111] Fix | Delete
141 => 'Write to pipe with no one reading',
[112] Fix | Delete
142 => 'Signal raised by alarm',
[113] Fix | Delete
143 => 'Termination (request to terminate)',
[114] Fix | Delete
// 144 - not defined
[115] Fix | Delete
145 => 'Child process terminated, stopped (or continued*)',
[116] Fix | Delete
146 => 'Continue if stopped',
[117] Fix | Delete
147 => 'Stop executing temporarily',
[118] Fix | Delete
148 => 'Terminal stop signal',
[119] Fix | Delete
149 => 'Background process attempting to read from tty ("in")',
[120] Fix | Delete
150 => 'Background process attempting to write to tty ("out")',
[121] Fix | Delete
151 => 'Urgent data available on socket',
[122] Fix | Delete
152 => 'CPU time limit exceeded',
[123] Fix | Delete
153 => 'File size limit exceeded',
[124] Fix | Delete
154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
[125] Fix | Delete
155 => 'Profiling timer expired',
[126] Fix | Delete
// 156 - not defined
[127] Fix | Delete
157 => 'Pollable event',
[128] Fix | Delete
// 158 - not defined
[129] Fix | Delete
159 => 'Bad syscall',
[130] Fix | Delete
];
[131] Fix | Delete
[132] Fix | Delete
/**
[133] Fix | Delete
* @param string|array $commandline The command line to run
[134] Fix | Delete
* @param string|null $cwd The working directory or null to use the working dir of the current PHP process
[135] Fix | Delete
* @param array|null $env The environment variables or null to use the same environment as the current PHP process
[136] Fix | Delete
* @param mixed|null $input The input as stream resource, scalar or \Traversable, or null for no input
[137] Fix | Delete
* @param int|float|null $timeout The timeout in seconds or null to disable
[138] Fix | Delete
* @param array $options An array of options for proc_open
[139] Fix | Delete
*
[140] Fix | Delete
* @throws RuntimeException When proc_open is not installed
[141] Fix | Delete
*/
[142] Fix | Delete
public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = null)
[143] Fix | Delete
{
[144] Fix | Delete
if (!\function_exists('proc_open')) {
[145] Fix | Delete
throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
$this->commandline = $commandline;
[149] Fix | Delete
$this->cwd = $cwd;
[150] Fix | Delete
[151] Fix | Delete
// on Windows, if the cwd changed via chdir(), proc_open defaults to the dir where PHP was started
[152] Fix | Delete
// on Gnu/Linux, PHP builds with --enable-maintainer-zts are also affected
[153] Fix | Delete
// @see : https://bugs.php.net/51800
[154] Fix | Delete
// @see : https://bugs.php.net/50524
[155] Fix | Delete
if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
[156] Fix | Delete
$this->cwd = getcwd();
[157] Fix | Delete
}
[158] Fix | Delete
if (null !== $env) {
[159] Fix | Delete
$this->setEnv($env);
[160] Fix | Delete
}
[161] Fix | Delete
[162] Fix | Delete
$this->setInput($input);
[163] Fix | Delete
$this->setTimeout($timeout);
[164] Fix | Delete
$this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
[165] Fix | Delete
$this->pty = false;
[166] Fix | Delete
$this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
[167] Fix | Delete
if (null !== $options) {
[168] Fix | Delete
@trigger_error(sprintf('The $options parameter of the %s constructor is deprecated since Symfony 3.3 and will be removed in 4.0.', __CLASS__), \E_USER_DEPRECATED);
[169] Fix | Delete
$this->options = array_replace($this->options, $options);
[170] Fix | Delete
}
[171] Fix | Delete
}
[172] Fix | Delete
[173] Fix | Delete
public function __destruct()
[174] Fix | Delete
{
[175] Fix | Delete
$this->stop(0);
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
public function __clone()
[179] Fix | Delete
{
[180] Fix | Delete
$this->resetProcessData();
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* Runs the process.
[185] Fix | Delete
*
[186] Fix | Delete
* The callback receives the type of output (out or err) and
[187] Fix | Delete
* some bytes from the output in real-time. It allows to have feedback
[188] Fix | Delete
* from the independent process during execution.
[189] Fix | Delete
*
[190] Fix | Delete
* The STDOUT and STDERR are also available after the process is finished
[191] Fix | Delete
* via the getOutput() and getErrorOutput() methods.
[192] Fix | Delete
*
[193] Fix | Delete
* @param callable|null $callback A PHP callback to run whenever there is some
[194] Fix | Delete
* output available on STDOUT or STDERR
[195] Fix | Delete
*
[196] Fix | Delete
* @return int The exit status code
[197] Fix | Delete
*
[198] Fix | Delete
* @throws RuntimeException When process can't be launched
[199] Fix | Delete
* @throws RuntimeException When process stopped after receiving signal
[200] Fix | Delete
* @throws LogicException In case a callback is provided and output has been disabled
[201] Fix | Delete
*
[202] Fix | Delete
* @final since version 3.3
[203] Fix | Delete
*/
[204] Fix | Delete
public function run($callback = null/*, array $env = []*/)
[205] Fix | Delete
{
[206] Fix | Delete
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
[207] Fix | Delete
$this->start($callback, $env);
[208] Fix | Delete
[209] Fix | Delete
return $this->wait();
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
/**
[213] Fix | Delete
* Runs the process.
[214] Fix | Delete
*
[215] Fix | Delete
* This is identical to run() except that an exception is thrown if the process
[216] Fix | Delete
* exits with a non-zero exit code.
[217] Fix | Delete
*
[218] Fix | Delete
* @return $this
[219] Fix | Delete
*
[220] Fix | Delete
* @throws RuntimeException if PHP was compiled with --enable-sigchild and the enhanced sigchild compatibility mode is not enabled
[221] Fix | Delete
* @throws ProcessFailedException if the process didn't terminate successfully
[222] Fix | Delete
*
[223] Fix | Delete
* @final since version 3.3
[224] Fix | Delete
*/
[225] Fix | Delete
public function mustRun(callable $callback = null/*, array $env = []*/)
[226] Fix | Delete
{
[227] Fix | Delete
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
[228] Fix | Delete
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
[229] Fix | Delete
}
[230] Fix | Delete
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
[231] Fix | Delete
[232] Fix | Delete
if (0 !== $this->run($callback, $env)) {
[233] Fix | Delete
throw new ProcessFailedException($this);
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
return $this;
[237] Fix | Delete
}
[238] Fix | Delete
[239] Fix | Delete
/**
[240] Fix | Delete
* Starts the process and returns after writing the input to STDIN.
[241] Fix | Delete
*
[242] Fix | Delete
* This method blocks until all STDIN data is sent to the process then it
[243] Fix | Delete
* returns while the process runs in the background.
[244] Fix | Delete
*
[245] Fix | Delete
* The termination of the process can be awaited with wait().
[246] Fix | Delete
*
[247] Fix | Delete
* The callback receives the type of output (out or err) and some bytes from
[248] Fix | Delete
* the output in real-time while writing the standard input to the process.
[249] Fix | Delete
* It allows to have feedback from the independent process during execution.
[250] Fix | Delete
*
[251] Fix | Delete
* @param callable|null $callback A PHP callback to run whenever there is some
[252] Fix | Delete
* output available on STDOUT or STDERR
[253] Fix | Delete
*
[254] Fix | Delete
* @throws RuntimeException When process can't be launched
[255] Fix | Delete
* @throws RuntimeException When process is already running
[256] Fix | Delete
* @throws LogicException In case a callback is provided and output has been disabled
[257] Fix | Delete
*/
[258] Fix | Delete
public function start(callable $callback = null/*, array $env = [*/)
[259] Fix | Delete
{
[260] Fix | Delete
if ($this->isRunning()) {
[261] Fix | Delete
throw new RuntimeException('Process is already running.');
[262] Fix | Delete
}
[263] Fix | Delete
if (2 <= \func_num_args()) {
[264] Fix | Delete
$env = func_get_arg(1);
[265] Fix | Delete
} else {
[266] Fix | Delete
if (__CLASS__ !== static::class) {
[267] Fix | Delete
$r = new \ReflectionMethod($this, __FUNCTION__);
[268] Fix | Delete
if (__CLASS__ !== $r->getDeclaringClass()->getName() && (2 > $r->getNumberOfParameters() || 'env' !== $r->getParameters()[1]->name)) {
[269] Fix | Delete
@trigger_error(sprintf('The %s::start() method expects a second "$env" argument since Symfony 3.3. It will be made mandatory in 4.0.', static::class), \E_USER_DEPRECATED);
[270] Fix | Delete
}
[271] Fix | Delete
}
[272] Fix | Delete
$env = null;
[273] Fix | Delete
}
[274] Fix | Delete
[275] Fix | Delete
$this->resetProcessData();
[276] Fix | Delete
$this->starttime = $this->lastOutputTime = microtime(true);
[277] Fix | Delete
$this->callback = $this->buildCallback($callback);
[278] Fix | Delete
$this->hasCallback = null !== $callback;
[279] Fix | Delete
$descriptors = $this->getDescriptors();
[280] Fix | Delete
$inheritEnv = $this->inheritEnv;
[281] Fix | Delete
[282] Fix | Delete
if (\is_array($commandline = $this->commandline)) {
[283] Fix | Delete
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
[284] Fix | Delete
[285] Fix | Delete
if ('\\' !== \DIRECTORY_SEPARATOR) {
[286] Fix | Delete
// exec is mandatory to deal with sending a signal to the process
[287] Fix | Delete
$commandline = 'exec '.$commandline;
[288] Fix | Delete
}
[289] Fix | Delete
}
[290] Fix | Delete
[291] Fix | Delete
if (null === $env) {
[292] Fix | Delete
$env = $this->env;
[293] Fix | Delete
} else {
[294] Fix | Delete
if ($this->env) {
[295] Fix | Delete
$env += $this->env;
[296] Fix | Delete
}
[297] Fix | Delete
$inheritEnv = true;
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
if (null !== $env && $inheritEnv) {
[301] Fix | Delete
$env += $this->getDefaultEnv();
[302] Fix | Delete
} elseif (null !== $env) {
[303] Fix | Delete
@trigger_error('Not inheriting environment variables is deprecated since Symfony 3.3 and will always happen in 4.0. Set "Process::inheritEnvironmentVariables()" to true instead.', \E_USER_DEPRECATED);
[304] Fix | Delete
} else {
[305] Fix | Delete
$env = $this->getDefaultEnv();
[306] Fix | Delete
}
[307] Fix | Delete
if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
[308] Fix | Delete
$this->options['bypass_shell'] = true;
[309] Fix | Delete
$commandline = $this->prepareWindowsCommandLine($commandline, $env);
[310] Fix | Delete
} elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
[311] Fix | Delete
// last exit code is output on the fourth pipe and caught to work around --enable-sigchild
[312] Fix | Delete
$descriptors[3] = ['pipe', 'w'];
[313] Fix | Delete
[314] Fix | Delete
// See https://unix.stackexchange.com/questions/71205/background-process-pipe-input
[315] Fix | Delete
$commandline = '{ ('.$commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
[316] Fix | Delete
$commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
[317] Fix | Delete
[318] Fix | Delete
// Workaround for the bug, when PTS functionality is enabled.
[319] Fix | Delete
// @see : https://bugs.php.net/69442
[320] Fix | Delete
$ptsWorkaround = fopen(__FILE__, 'r');
[321] Fix | Delete
}
[322] Fix | Delete
if (\defined('HHVM_VERSION')) {
[323] Fix | Delete
$envPairs = $env;
[324] Fix | Delete
} else {
[325] Fix | Delete
$envPairs = [];
[326] Fix | Delete
foreach ($env as $k => $v) {
[327] Fix | Delete
if (false !== $v) {
[328] Fix | Delete
$envPairs[] = $k.'='.$v;
[329] Fix | Delete
}
[330] Fix | Delete
}
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
if (!is_dir($this->cwd)) {
[334] Fix | Delete
@trigger_error('The provided cwd does not exist. Command is currently ran against getcwd(). This behavior is deprecated since Symfony 3.4 and will be removed in 4.0.', \E_USER_DEPRECATED);
[335] Fix | Delete
}
[336] Fix | Delete
[337] Fix | Delete
$this->process = @proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $envPairs, $this->options);
[338] Fix | Delete
[339] Fix | Delete
if (!\is_resource($this->process)) {
[340] Fix | Delete
throw new RuntimeException('Unable to launch a new process.');
[341] Fix | Delete
}
[342] Fix | Delete
$this->status = self::STATUS_STARTED;
[343] Fix | Delete
[344] Fix | Delete
if (isset($descriptors[3])) {
[345] Fix | Delete
$this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
if ($this->tty) {
[349] Fix | Delete
return;
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
$this->updateStatus(false);
[353] Fix | Delete
$this->checkTimeout();
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Restarts the process.
[358] Fix | Delete
*
[359] Fix | Delete
* Be warned that the process is cloned before being started.
[360] Fix | Delete
*
[361] Fix | Delete
* @param callable|null $callback A PHP callback to run whenever there is some
[362] Fix | Delete
* output available on STDOUT or STDERR
[363] Fix | Delete
*
[364] Fix | Delete
* @return static
[365] Fix | Delete
*
[366] Fix | Delete
* @throws RuntimeException When process can't be launched
[367] Fix | Delete
* @throws RuntimeException When process is already running
[368] Fix | Delete
*
[369] Fix | Delete
* @see start()
[370] Fix | Delete
*
[371] Fix | Delete
* @final since version 3.3
[372] Fix | Delete
*/
[373] Fix | Delete
public function restart(callable $callback = null/*, array $env = []*/)
[374] Fix | Delete
{
[375] Fix | Delete
if ($this->isRunning()) {
[376] Fix | Delete
throw new RuntimeException('Process is already running.');
[377] Fix | Delete
}
[378] Fix | Delete
$env = 1 < \func_num_args() ? func_get_arg(1) : null;
[379] Fix | Delete
[380] Fix | Delete
$process = clone $this;
[381] Fix | Delete
$process->start($callback, $env);
[382] Fix | Delete
[383] Fix | Delete
return $process;
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
/**
[387] Fix | Delete
* Waits for the process to terminate.
[388] Fix | Delete
*
[389] Fix | Delete
* The callback receives the type of output (out or err) and some bytes
[390] Fix | Delete
* from the output in real-time while writing the standard input to the process.
[391] Fix | Delete
* It allows to have feedback from the independent process during execution.
[392] Fix | Delete
*
[393] Fix | Delete
* @param callable|null $callback A valid PHP callback
[394] Fix | Delete
*
[395] Fix | Delete
* @return int The exitcode of the process
[396] Fix | Delete
*
[397] Fix | Delete
* @throws RuntimeException When process timed out
[398] Fix | Delete
* @throws RuntimeException When process stopped after receiving signal
[399] Fix | Delete
* @throws LogicException When process is not yet started
[400] Fix | Delete
*/
[401] Fix | Delete
public function wait(callable $callback = null)
[402] Fix | Delete
{
[403] Fix | Delete
$this->requireProcessIsStarted(__FUNCTION__);
[404] Fix | Delete
[405] Fix | Delete
$this->updateStatus(false);
[406] Fix | Delete
[407] Fix | Delete
if (null !== $callback) {
[408] Fix | Delete
if (!$this->processPipes->haveReadSupport()) {
[409] Fix | Delete
$this->stop(0);
[410] Fix | Delete
throw new \LogicException('Pass the callback to the Process::start method or enableOutput to use a callback with Process::wait.');
[411] Fix | Delete
}
[412] Fix | Delete
$this->callback = $this->buildCallback($callback);
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
do {
[416] Fix | Delete
$this->checkTimeout();
[417] Fix | Delete
$running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
[418] Fix | Delete
$this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
[419] Fix | Delete
} while ($running);
[420] Fix | Delete
[421] Fix | Delete
while ($this->isRunning()) {
[422] Fix | Delete
$this->checkTimeout();
[423] Fix | Delete
usleep(1000);
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
[427] Fix | Delete
throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
return $this->exitcode;
[431] Fix | Delete
}
[432] Fix | Delete
[433] Fix | Delete
/**
[434] Fix | Delete
* Returns the Pid (process identifier), if applicable.
[435] Fix | Delete
*
[436] Fix | Delete
* @return int|null The process id if running, null otherwise
[437] Fix | Delete
*/
[438] Fix | Delete
public function getPid()
[439] Fix | Delete
{
[440] Fix | Delete
return $this->isRunning() ? $this->processInformation['pid'] : null;
[441] Fix | Delete
}
[442] Fix | Delete
[443] Fix | Delete
/**
[444] Fix | Delete
* Sends a POSIX signal to the process.
[445] Fix | Delete
*
[446] Fix | Delete
* @param int $signal A valid POSIX signal (see https://php.net/pcntl.constants)
[447] Fix | Delete
*
[448] Fix | Delete
* @return $this
[449] Fix | Delete
*
[450] Fix | Delete
* @throws LogicException In case the process is not running
[451] Fix | Delete
* @throws RuntimeException In case --enable-sigchild is activated and the process can't be killed
[452] Fix | Delete
* @throws RuntimeException In case of failure
[453] Fix | Delete
*/
[454] Fix | Delete
public function signal($signal)
[455] Fix | Delete
{
[456] Fix | Delete
$this->doSignal($signal, true);
[457] Fix | Delete
[458] Fix | Delete
return $this;
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
/**
[462] Fix | Delete
* Disables fetching output and error output from the underlying process.
[463] Fix | Delete
*
[464] Fix | Delete
* @return $this
[465] Fix | Delete
*
[466] Fix | Delete
* @throws RuntimeException In case the process is already running
[467] Fix | Delete
* @throws LogicException if an idle timeout is set
[468] Fix | Delete
*/
[469] Fix | Delete
public function disableOutput()
[470] Fix | Delete
{
[471] Fix | Delete
if ($this->isRunning()) {
[472] Fix | Delete
throw new RuntimeException('Disabling output while the process is running is not possible.');
[473] Fix | Delete
}
[474] Fix | Delete
if (null !== $this->idleTimeout) {
[475] Fix | Delete
throw new LogicException('Output can not be disabled while an idle timeout is set.');
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
$this->outputDisabled = true;
[479] Fix | Delete
[480] Fix | Delete
return $this;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* Enables fetching output and error output from the underlying process.
[485] Fix | Delete
*
[486] Fix | Delete
* @return $this
[487] Fix | Delete
*
[488] Fix | Delete
* @throws RuntimeException In case the process is already running
[489] Fix | Delete
*/
[490] Fix | Delete
public function enableOutput()
[491] Fix | Delete
{
[492] Fix | Delete
if ($this->isRunning()) {
[493] Fix | Delete
throw new RuntimeException('Enabling output while the process is running is not possible.');
[494] Fix | Delete
}
[495] Fix | Delete
[496] Fix | Delete
$this->outputDisabled = false;
[497] Fix | Delete
[498] Fix | Delete
return $this;
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function