Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/symfony/process/Pipes
File: UnixPipes.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\Pipes;
[11] Fix | Delete
[12] Fix | Delete
use Symfony\Component\Process\Process;
[13] Fix | Delete
[14] Fix | Delete
/**
[15] Fix | Delete
* UnixPipes implementation uses unix pipes as handles.
[16] Fix | Delete
*
[17] Fix | Delete
* @author Romain Neutron <imprec@gmail.com>
[18] Fix | Delete
*
[19] Fix | Delete
* @internal
[20] Fix | Delete
*/
[21] Fix | Delete
class UnixPipes extends AbstractPipes
[22] Fix | Delete
{
[23] Fix | Delete
private $ttyMode;
[24] Fix | Delete
private $ptyMode;
[25] Fix | Delete
private $haveReadSupport;
[26] Fix | Delete
[27] Fix | Delete
public function __construct($ttyMode, $ptyMode, $input, $haveReadSupport)
[28] Fix | Delete
{
[29] Fix | Delete
$this->ttyMode = (bool) $ttyMode;
[30] Fix | Delete
$this->ptyMode = (bool) $ptyMode;
[31] Fix | Delete
$this->haveReadSupport = (bool) $haveReadSupport;
[32] Fix | Delete
[33] Fix | Delete
parent::__construct($input);
[34] Fix | Delete
}
[35] Fix | Delete
[36] Fix | Delete
public function __destruct()
[37] Fix | Delete
{
[38] Fix | Delete
$this->close();
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* {@inheritdoc}
[43] Fix | Delete
*/
[44] Fix | Delete
public function getDescriptors()
[45] Fix | Delete
{
[46] Fix | Delete
if (!$this->haveReadSupport) {
[47] Fix | Delete
$nullstream = fopen('/dev/null', 'c');
[48] Fix | Delete
[49] Fix | Delete
return [
[50] Fix | Delete
['pipe', 'r'],
[51] Fix | Delete
$nullstream,
[52] Fix | Delete
$nullstream,
[53] Fix | Delete
];
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
if ($this->ttyMode) {
[57] Fix | Delete
return [
[58] Fix | Delete
['file', '/dev/tty', 'r'],
[59] Fix | Delete
['file', '/dev/tty', 'w'],
[60] Fix | Delete
['file', '/dev/tty', 'w'],
[61] Fix | Delete
];
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
if ($this->ptyMode && Process::isPtySupported()) {
[65] Fix | Delete
return [
[66] Fix | Delete
['pty'],
[67] Fix | Delete
['pty'],
[68] Fix | Delete
['pty'],
[69] Fix | Delete
];
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
return [
[73] Fix | Delete
['pipe', 'r'],
[74] Fix | Delete
['pipe', 'w'], // stdout
[75] Fix | Delete
['pipe', 'w'], // stderr
[76] Fix | Delete
];
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
/**
[80] Fix | Delete
* {@inheritdoc}
[81] Fix | Delete
*/
[82] Fix | Delete
public function getFiles()
[83] Fix | Delete
{
[84] Fix | Delete
return [];
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* {@inheritdoc}
[89] Fix | Delete
*/
[90] Fix | Delete
public function readAndWrite($blocking, $close = false)
[91] Fix | Delete
{
[92] Fix | Delete
$this->unblock();
[93] Fix | Delete
$w = $this->write();
[94] Fix | Delete
[95] Fix | Delete
$read = $e = [];
[96] Fix | Delete
$r = $this->pipes;
[97] Fix | Delete
unset($r[0]);
[98] Fix | Delete
[99] Fix | Delete
// let's have a look if something changed in streams
[100] Fix | Delete
set_error_handler([$this, 'handleError']);
[101] Fix | Delete
if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
[102] Fix | Delete
restore_error_handler();
[103] Fix | Delete
// if a system call has been interrupted, forget about it, let's try again
[104] Fix | Delete
// otherwise, an error occurred, let's reset pipes
[105] Fix | Delete
if (!$this->hasSystemCallBeenInterrupted()) {
[106] Fix | Delete
$this->pipes = [];
[107] Fix | Delete
}
[108] Fix | Delete
[109] Fix | Delete
return $read;
[110] Fix | Delete
}
[111] Fix | Delete
restore_error_handler();
[112] Fix | Delete
[113] Fix | Delete
foreach ($r as $pipe) {
[114] Fix | Delete
// prior PHP 5.4 the array passed to stream_select is modified and
[115] Fix | Delete
// lose key association, we have to find back the key
[116] Fix | Delete
$read[$type = array_search($pipe, $this->pipes, true)] = '';
[117] Fix | Delete
[118] Fix | Delete
do {
[119] Fix | Delete
$data = @fread($pipe, self::CHUNK_SIZE);
[120] Fix | Delete
$read[$type] .= $data;
[121] Fix | Delete
} while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
[122] Fix | Delete
[123] Fix | Delete
if (!isset($read[$type][0])) {
[124] Fix | Delete
unset($read[$type]);
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
if ($close && feof($pipe)) {
[128] Fix | Delete
fclose($pipe);
[129] Fix | Delete
unset($this->pipes[$type]);
[130] Fix | Delete
}
[131] Fix | Delete
}
[132] Fix | Delete
[133] Fix | Delete
return $read;
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
/**
[137] Fix | Delete
* {@inheritdoc}
[138] Fix | Delete
*/
[139] Fix | Delete
public function haveReadSupport()
[140] Fix | Delete
{
[141] Fix | Delete
return $this->haveReadSupport;
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
/**
[145] Fix | Delete
* {@inheritdoc}
[146] Fix | Delete
*/
[147] Fix | Delete
public function areOpen()
[148] Fix | Delete
{
[149] Fix | Delete
return (bool) $this->pipes;
[150] Fix | Delete
}
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function