Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/process
File: Process.php
}
[500] Fix | Delete
[501] Fix | Delete
/**
[502] Fix | Delete
* Returns true in case the output is disabled, false otherwise.
[503] Fix | Delete
*
[504] Fix | Delete
* @return bool
[505] Fix | Delete
*/
[506] Fix | Delete
public function isOutputDisabled()
[507] Fix | Delete
{
[508] Fix | Delete
return $this->outputDisabled;
[509] Fix | Delete
}
[510] Fix | Delete
[511] Fix | Delete
/**
[512] Fix | Delete
* Returns the current output of the process (STDOUT).
[513] Fix | Delete
*
[514] Fix | Delete
* @return string The process output
[515] Fix | Delete
*
[516] Fix | Delete
* @throws LogicException in case the output has been disabled
[517] Fix | Delete
* @throws LogicException In case the process is not started
[518] Fix | Delete
*/
[519] Fix | Delete
public function getOutput()
[520] Fix | Delete
{
[521] Fix | Delete
$this->readPipesForOutput(__FUNCTION__);
[522] Fix | Delete
[523] Fix | Delete
if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
[524] Fix | Delete
return '';
[525] Fix | Delete
}
[526] Fix | Delete
[527] Fix | Delete
return $ret;
[528] Fix | Delete
}
[529] Fix | Delete
[530] Fix | Delete
/**
[531] Fix | Delete
* Returns the output incrementally.
[532] Fix | Delete
*
[533] Fix | Delete
* In comparison with the getOutput method which always return the whole
[534] Fix | Delete
* output, this one returns the new output since the last call.
[535] Fix | Delete
*
[536] Fix | Delete
* @return string The process output since the last call
[537] Fix | Delete
*
[538] Fix | Delete
* @throws LogicException in case the output has been disabled
[539] Fix | Delete
* @throws LogicException In case the process is not started
[540] Fix | Delete
*/
[541] Fix | Delete
public function getIncrementalOutput()
[542] Fix | Delete
{
[543] Fix | Delete
$this->readPipesForOutput(__FUNCTION__);
[544] Fix | Delete
[545] Fix | Delete
$latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
[546] Fix | Delete
$this->incrementalOutputOffset = ftell($this->stdout);
[547] Fix | Delete
[548] Fix | Delete
if (false === $latest) {
[549] Fix | Delete
return '';
[550] Fix | Delete
}
[551] Fix | Delete
[552] Fix | Delete
return $latest;
[553] Fix | Delete
}
[554] Fix | Delete
[555] Fix | Delete
/**
[556] Fix | Delete
* Returns an iterator to the output of the process, with the output type as keys (Process::OUT/ERR).
[557] Fix | Delete
*
[558] Fix | Delete
* @param int $flags A bit field of Process::ITER_* flags
[559] Fix | Delete
*
[560] Fix | Delete
* @throws LogicException in case the output has been disabled
[561] Fix | Delete
* @throws LogicException In case the process is not started
[562] Fix | Delete
*
[563] Fix | Delete
* @return \Generator
[564] Fix | Delete
*/
[565] Fix | Delete
public function getIterator($flags = 0)
[566] Fix | Delete
{
[567] Fix | Delete
$this->readPipesForOutput(__FUNCTION__, false);
[568] Fix | Delete
[569] Fix | Delete
$clearOutput = !(self::ITER_KEEP_OUTPUT & $flags);
[570] Fix | Delete
$blocking = !(self::ITER_NON_BLOCKING & $flags);
[571] Fix | Delete
$yieldOut = !(self::ITER_SKIP_OUT & $flags);
[572] Fix | Delete
$yieldErr = !(self::ITER_SKIP_ERR & $flags);
[573] Fix | Delete
[574] Fix | Delete
while (null !== $this->callback || ($yieldOut && !feof($this->stdout)) || ($yieldErr && !feof($this->stderr))) {
[575] Fix | Delete
if ($yieldOut) {
[576] Fix | Delete
$out = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
[577] Fix | Delete
[578] Fix | Delete
if (isset($out[0])) {
[579] Fix | Delete
if ($clearOutput) {
[580] Fix | Delete
$this->clearOutput();
[581] Fix | Delete
} else {
[582] Fix | Delete
$this->incrementalOutputOffset = ftell($this->stdout);
[583] Fix | Delete
}
[584] Fix | Delete
[585] Fix | Delete
yield self::OUT => $out;
[586] Fix | Delete
}
[587] Fix | Delete
}
[588] Fix | Delete
[589] Fix | Delete
if ($yieldErr) {
[590] Fix | Delete
$err = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
[591] Fix | Delete
[592] Fix | Delete
if (isset($err[0])) {
[593] Fix | Delete
if ($clearOutput) {
[594] Fix | Delete
$this->clearErrorOutput();
[595] Fix | Delete
} else {
[596] Fix | Delete
$this->incrementalErrorOutputOffset = ftell($this->stderr);
[597] Fix | Delete
}
[598] Fix | Delete
[599] Fix | Delete
yield self::ERR => $err;
[600] Fix | Delete
}
[601] Fix | Delete
}
[602] Fix | Delete
[603] Fix | Delete
if (!$blocking && !isset($out[0]) && !isset($err[0])) {
[604] Fix | Delete
yield self::OUT => '';
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
$this->checkTimeout();
[608] Fix | Delete
$this->readPipesForOutput(__FUNCTION__, $blocking);
[609] Fix | Delete
}
[610] Fix | Delete
}
[611] Fix | Delete
[612] Fix | Delete
/**
[613] Fix | Delete
* Clears the process output.
[614] Fix | Delete
*
[615] Fix | Delete
* @return $this
[616] Fix | Delete
*/
[617] Fix | Delete
public function clearOutput()
[618] Fix | Delete
{
[619] Fix | Delete
ftruncate($this->stdout, 0);
[620] Fix | Delete
fseek($this->stdout, 0);
[621] Fix | Delete
$this->incrementalOutputOffset = 0;
[622] Fix | Delete
[623] Fix | Delete
return $this;
[624] Fix | Delete
}
[625] Fix | Delete
[626] Fix | Delete
/**
[627] Fix | Delete
* Returns the current error output of the process (STDERR).
[628] Fix | Delete
*
[629] Fix | Delete
* @return string The process error output
[630] Fix | Delete
*
[631] Fix | Delete
* @throws LogicException in case the output has been disabled
[632] Fix | Delete
* @throws LogicException In case the process is not started
[633] Fix | Delete
*/
[634] Fix | Delete
public function getErrorOutput()
[635] Fix | Delete
{
[636] Fix | Delete
$this->readPipesForOutput(__FUNCTION__);
[637] Fix | Delete
[638] Fix | Delete
if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
[639] Fix | Delete
return '';
[640] Fix | Delete
}
[641] Fix | Delete
[642] Fix | Delete
return $ret;
[643] Fix | Delete
}
[644] Fix | Delete
[645] Fix | Delete
/**
[646] Fix | Delete
* Returns the errorOutput incrementally.
[647] Fix | Delete
*
[648] Fix | Delete
* In comparison with the getErrorOutput method which always return the
[649] Fix | Delete
* whole error output, this one returns the new error output since the last
[650] Fix | Delete
* call.
[651] Fix | Delete
*
[652] Fix | Delete
* @return string The process error output since the last call
[653] Fix | Delete
*
[654] Fix | Delete
* @throws LogicException in case the output has been disabled
[655] Fix | Delete
* @throws LogicException In case the process is not started
[656] Fix | Delete
*/
[657] Fix | Delete
public function getIncrementalErrorOutput()
[658] Fix | Delete
{
[659] Fix | Delete
$this->readPipesForOutput(__FUNCTION__);
[660] Fix | Delete
[661] Fix | Delete
$latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
[662] Fix | Delete
$this->incrementalErrorOutputOffset = ftell($this->stderr);
[663] Fix | Delete
[664] Fix | Delete
if (false === $latest) {
[665] Fix | Delete
return '';
[666] Fix | Delete
}
[667] Fix | Delete
[668] Fix | Delete
return $latest;
[669] Fix | Delete
}
[670] Fix | Delete
[671] Fix | Delete
/**
[672] Fix | Delete
* Clears the process output.
[673] Fix | Delete
*
[674] Fix | Delete
* @return $this
[675] Fix | Delete
*/
[676] Fix | Delete
public function clearErrorOutput()
[677] Fix | Delete
{
[678] Fix | Delete
ftruncate($this->stderr, 0);
[679] Fix | Delete
fseek($this->stderr, 0);
[680] Fix | Delete
$this->incrementalErrorOutputOffset = 0;
[681] Fix | Delete
[682] Fix | Delete
return $this;
[683] Fix | Delete
}
[684] Fix | Delete
[685] Fix | Delete
/**
[686] Fix | Delete
* Returns the exit code returned by the process.
[687] Fix | Delete
*
[688] Fix | Delete
* @return int|null The exit status code, null if the Process is not terminated
[689] Fix | Delete
*
[690] Fix | Delete
* @throws RuntimeException In case --enable-sigchild is activated and the sigchild compatibility mode is disabled
[691] Fix | Delete
*/
[692] Fix | Delete
public function getExitCode()
[693] Fix | Delete
{
[694] Fix | Delete
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
[695] Fix | Delete
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
[696] Fix | Delete
}
[697] Fix | Delete
[698] Fix | Delete
$this->updateStatus(false);
[699] Fix | Delete
[700] Fix | Delete
return $this->exitcode;
[701] Fix | Delete
}
[702] Fix | Delete
[703] Fix | Delete
/**
[704] Fix | Delete
* Returns a string representation for the exit code returned by the process.
[705] Fix | Delete
*
[706] Fix | Delete
* This method relies on the Unix exit code status standardization
[707] Fix | Delete
* and might not be relevant for other operating systems.
[708] Fix | Delete
*
[709] Fix | Delete
* @return string|null A string representation for the exit status code, null if the Process is not terminated
[710] Fix | Delete
*
[711] Fix | Delete
* @see http://tldp.org/LDP/abs/html/exitcodes.html
[712] Fix | Delete
* @see http://en.wikipedia.org/wiki/Unix_signal
[713] Fix | Delete
*/
[714] Fix | Delete
public function getExitCodeText()
[715] Fix | Delete
{
[716] Fix | Delete
if (null === $exitcode = $this->getExitCode()) {
[717] Fix | Delete
return null;
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
[721] Fix | Delete
}
[722] Fix | Delete
[723] Fix | Delete
/**
[724] Fix | Delete
* Checks if the process ended successfully.
[725] Fix | Delete
*
[726] Fix | Delete
* @return bool true if the process ended successfully, false otherwise
[727] Fix | Delete
*/
[728] Fix | Delete
public function isSuccessful()
[729] Fix | Delete
{
[730] Fix | Delete
return 0 === $this->getExitCode();
[731] Fix | Delete
}
[732] Fix | Delete
[733] Fix | Delete
/**
[734] Fix | Delete
* Returns true if the child process has been terminated by an uncaught signal.
[735] Fix | Delete
*
[736] Fix | Delete
* It always returns false on Windows.
[737] Fix | Delete
*
[738] Fix | Delete
* @return bool
[739] Fix | Delete
*
[740] Fix | Delete
* @throws RuntimeException In case --enable-sigchild is activated
[741] Fix | Delete
* @throws LogicException In case the process is not terminated
[742] Fix | Delete
*/
[743] Fix | Delete
public function hasBeenSignaled()
[744] Fix | Delete
{
[745] Fix | Delete
$this->requireProcessIsTerminated(__FUNCTION__);
[746] Fix | Delete
[747] Fix | Delete
if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
[748] Fix | Delete
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
return $this->processInformation['signaled'];
[752] Fix | Delete
}
[753] Fix | Delete
[754] Fix | Delete
/**
[755] Fix | Delete
* Returns the number of the signal that caused the child process to terminate its execution.
[756] Fix | Delete
*
[757] Fix | Delete
* It is only meaningful if hasBeenSignaled() returns true.
[758] Fix | Delete
*
[759] Fix | Delete
* @return int
[760] Fix | Delete
*
[761] Fix | Delete
* @throws RuntimeException In case --enable-sigchild is activated
[762] Fix | Delete
* @throws LogicException In case the process is not terminated
[763] Fix | Delete
*/
[764] Fix | Delete
public function getTermSignal()
[765] Fix | Delete
{
[766] Fix | Delete
$this->requireProcessIsTerminated(__FUNCTION__);
[767] Fix | Delete
[768] Fix | Delete
if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
[769] Fix | Delete
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
[770] Fix | Delete
}
[771] Fix | Delete
[772] Fix | Delete
return $this->processInformation['termsig'];
[773] Fix | Delete
}
[774] Fix | Delete
[775] Fix | Delete
/**
[776] Fix | Delete
* Returns true if the child process has been stopped by a signal.
[777] Fix | Delete
*
[778] Fix | Delete
* It always returns false on Windows.
[779] Fix | Delete
*
[780] Fix | Delete
* @return bool
[781] Fix | Delete
*
[782] Fix | Delete
* @throws LogicException In case the process is not terminated
[783] Fix | Delete
*/
[784] Fix | Delete
public function hasBeenStopped()
[785] Fix | Delete
{
[786] Fix | Delete
$this->requireProcessIsTerminated(__FUNCTION__);
[787] Fix | Delete
[788] Fix | Delete
return $this->processInformation['stopped'];
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
/**
[792] Fix | Delete
* Returns the number of the signal that caused the child process to stop its execution.
[793] Fix | Delete
*
[794] Fix | Delete
* It is only meaningful if hasBeenStopped() returns true.
[795] Fix | Delete
*
[796] Fix | Delete
* @return int
[797] Fix | Delete
*
[798] Fix | Delete
* @throws LogicException In case the process is not terminated
[799] Fix | Delete
*/
[800] Fix | Delete
public function getStopSignal()
[801] Fix | Delete
{
[802] Fix | Delete
$this->requireProcessIsTerminated(__FUNCTION__);
[803] Fix | Delete
[804] Fix | Delete
return $this->processInformation['stopsig'];
[805] Fix | Delete
}
[806] Fix | Delete
[807] Fix | Delete
/**
[808] Fix | Delete
* Checks if the process is currently running.
[809] Fix | Delete
*
[810] Fix | Delete
* @return bool true if the process is currently running, false otherwise
[811] Fix | Delete
*/
[812] Fix | Delete
public function isRunning()
[813] Fix | Delete
{
[814] Fix | Delete
if (self::STATUS_STARTED !== $this->status) {
[815] Fix | Delete
return false;
[816] Fix | Delete
}
[817] Fix | Delete
[818] Fix | Delete
$this->updateStatus(false);
[819] Fix | Delete
[820] Fix | Delete
return $this->processInformation['running'];
[821] Fix | Delete
}
[822] Fix | Delete
[823] Fix | Delete
/**
[824] Fix | Delete
* Checks if the process has been started with no regard to the current state.
[825] Fix | Delete
*
[826] Fix | Delete
* @return bool true if status is ready, false otherwise
[827] Fix | Delete
*/
[828] Fix | Delete
public function isStarted()
[829] Fix | Delete
{
[830] Fix | Delete
return self::STATUS_READY != $this->status;
[831] Fix | Delete
}
[832] Fix | Delete
[833] Fix | Delete
/**
[834] Fix | Delete
* Checks if the process is terminated.
[835] Fix | Delete
*
[836] Fix | Delete
* @return bool true if process is terminated, false otherwise
[837] Fix | Delete
*/
[838] Fix | Delete
public function isTerminated()
[839] Fix | Delete
{
[840] Fix | Delete
$this->updateStatus(false);
[841] Fix | Delete
[842] Fix | Delete
return self::STATUS_TERMINATED == $this->status;
[843] Fix | Delete
}
[844] Fix | Delete
[845] Fix | Delete
/**
[846] Fix | Delete
* Gets the process status.
[847] Fix | Delete
*
[848] Fix | Delete
* The status is one of: ready, started, terminated.
[849] Fix | Delete
*
[850] Fix | Delete
* @return string The current process status
[851] Fix | Delete
*/
[852] Fix | Delete
public function getStatus()
[853] Fix | Delete
{
[854] Fix | Delete
$this->updateStatus(false);
[855] Fix | Delete
[856] Fix | Delete
return $this->status;
[857] Fix | Delete
}
[858] Fix | Delete
[859] Fix | Delete
/**
[860] Fix | Delete
* Stops the process.
[861] Fix | Delete
*
[862] Fix | Delete
* @param int|float $timeout The timeout in seconds
[863] Fix | Delete
* @param int $signal A POSIX signal to send in case the process has not stop at timeout, default is SIGKILL (9)
[864] Fix | Delete
*
[865] Fix | Delete
* @return int|null The exit-code of the process or null if it's not running
[866] Fix | Delete
*/
[867] Fix | Delete
public function stop($timeout = 10, $signal = null)
[868] Fix | Delete
{
[869] Fix | Delete
$timeoutMicro = microtime(true) + $timeout;
[870] Fix | Delete
if ($this->isRunning()) {
[871] Fix | Delete
// given `SIGTERM` may not be defined and that `proc_terminate` uses the constant value and not the constant itself, we use the same here
[872] Fix | Delete
$this->doSignal(15, false);
[873] Fix | Delete
do {
[874] Fix | Delete
usleep(1000);
[875] Fix | Delete
} while ($this->isRunning() && microtime(true) < $timeoutMicro);
[876] Fix | Delete
[877] Fix | Delete
if ($this->isRunning()) {
[878] Fix | Delete
// Avoid exception here: process is supposed to be running, but it might have stopped just
[879] Fix | Delete
// after this line. In any case, let's silently discard the error, we cannot do anything.
[880] Fix | Delete
$this->doSignal($signal ?: 9, false);
[881] Fix | Delete
}
[882] Fix | Delete
}
[883] Fix | Delete
[884] Fix | Delete
if ($this->isRunning()) {
[885] Fix | Delete
if (isset($this->fallbackStatus['pid'])) {
[886] Fix | Delete
unset($this->fallbackStatus['pid']);
[887] Fix | Delete
[888] Fix | Delete
return $this->stop(0, $signal);
[889] Fix | Delete
}
[890] Fix | Delete
$this->close();
[891] Fix | Delete
}
[892] Fix | Delete
[893] Fix | Delete
return $this->exitcode;
[894] Fix | Delete
}
[895] Fix | Delete
[896] Fix | Delete
/**
[897] Fix | Delete
* Adds a line to the STDOUT stream.
[898] Fix | Delete
*
[899] Fix | Delete
* @internal
[900] Fix | Delete
*
[901] Fix | Delete
* @param string $line The line to append
[902] Fix | Delete
*/
[903] Fix | Delete
public function addOutput($line)
[904] Fix | Delete
{
[905] Fix | Delete
$this->lastOutputTime = microtime(true);
[906] Fix | Delete
[907] Fix | Delete
fseek($this->stdout, 0, \SEEK_END);
[908] Fix | Delete
fwrite($this->stdout, $line);
[909] Fix | Delete
fseek($this->stdout, $this->incrementalOutputOffset);
[910] Fix | Delete
}
[911] Fix | Delete
[912] Fix | Delete
/**
[913] Fix | Delete
* Adds a line to the STDERR stream.
[914] Fix | Delete
*
[915] Fix | Delete
* @internal
[916] Fix | Delete
*
[917] Fix | Delete
* @param string $line The line to append
[918] Fix | Delete
*/
[919] Fix | Delete
public function addErrorOutput($line)
[920] Fix | Delete
{
[921] Fix | Delete
$this->lastOutputTime = microtime(true);
[922] Fix | Delete
[923] Fix | Delete
fseek($this->stderr, 0, \SEEK_END);
[924] Fix | Delete
fwrite($this->stderr, $line);
[925] Fix | Delete
fseek($this->stderr, $this->incrementalErrorOutputOffset);
[926] Fix | Delete
}
[927] Fix | Delete
[928] Fix | Delete
/**
[929] Fix | Delete
* Gets the command line to be executed.
[930] Fix | Delete
*
[931] Fix | Delete
* @return string The command to execute
[932] Fix | Delete
*/
[933] Fix | Delete
public function getCommandLine()
[934] Fix | Delete
{
[935] Fix | Delete
return \is_array($this->commandline) ? implode(' ', array_map([$this, 'escapeArgument'], $this->commandline)) : $this->commandline;
[936] Fix | Delete
}
[937] Fix | Delete
[938] Fix | Delete
/**
[939] Fix | Delete
* Sets the command line to be executed.
[940] Fix | Delete
*
[941] Fix | Delete
* @param string|array $commandline The command to execute
[942] Fix | Delete
*
[943] Fix | Delete
* @return $this
[944] Fix | Delete
*/
[945] Fix | Delete
public function setCommandLine($commandline)
[946] Fix | Delete
{
[947] Fix | Delete
$this->commandline = $commandline;
[948] Fix | Delete
[949] Fix | Delete
return $this;
[950] Fix | Delete
}
[951] Fix | Delete
[952] Fix | Delete
/**
[953] Fix | Delete
* Gets the process timeout (max. runtime).
[954] Fix | Delete
*
[955] Fix | Delete
* @return float|null The timeout in seconds or null if it's disabled
[956] Fix | Delete
*/
[957] Fix | Delete
public function getTimeout()
[958] Fix | Delete
{
[959] Fix | Delete
return $this->timeout;
[960] Fix | Delete
}
[961] Fix | Delete
[962] Fix | Delete
/**
[963] Fix | Delete
* Gets the process idle timeout (max. time since last output).
[964] Fix | Delete
*
[965] Fix | Delete
* @return float|null The timeout in seconds or null if it's disabled
[966] Fix | Delete
*/
[967] Fix | Delete
public function getIdleTimeout()
[968] Fix | Delete
{
[969] Fix | Delete
return $this->idleTimeout;
[970] Fix | Delete
}
[971] Fix | Delete
[972] Fix | Delete
/**
[973] Fix | Delete
* Sets the process timeout (max. runtime) in seconds.
[974] Fix | Delete
*
[975] Fix | Delete
* To disable the timeout, set this value to null.
[976] Fix | Delete
*
[977] Fix | Delete
* @param int|float|null $timeout The timeout in seconds
[978] Fix | Delete
*
[979] Fix | Delete
* @return $this
[980] Fix | Delete
*
[981] Fix | Delete
* @throws InvalidArgumentException if the timeout is negative
[982] Fix | Delete
*/
[983] Fix | Delete
public function setTimeout($timeout)
[984] Fix | Delete
{
[985] Fix | Delete
$this->timeout = $this->validateTimeout($timeout);
[986] Fix | Delete
[987] Fix | Delete
return $this;
[988] Fix | Delete
}
[989] Fix | Delete
[990] Fix | Delete
/**
[991] Fix | Delete
* Sets the process idle timeout (max. time since last output).
[992] Fix | Delete
*
[993] Fix | Delete
* To disable the timeout, set this value to null.
[994] Fix | Delete
*
[995] Fix | Delete
* @param int|float|null $timeout The timeout in seconds
[996] Fix | Delete
*
[997] Fix | Delete
* @return $this
[998] Fix | Delete
*
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function