54 $tmpDir = sys_get_temp_dir();
56 set_error_handler(
function ($type, $msg) use (&
$error) {
$error = $msg; });
58 foreach (
$pipes as $pipe => $name) {
59 $file =
sprintf(
'%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
64 if (!
$h &&
false === strpos(
$error,
'File exists')) {
65 restore_error_handler();
68 if (!
$h || !$this->fileHandles[$pipe] = fopen(
$file,
'rb')) {
71 if (isset($this->files[$pipe])) {
72 unlink($this->files[$pipe]);
74 $this->files[$pipe] =
$file;
78 restore_error_handler();
81 parent::__construct(
$input);
96 $nullstream = fopen(
'NUL',
'c');
110 array(
'file',
'NUL',
'w'),
111 array(
'file',
'NUL',
'w'),
135 } elseif ($this->fileHandles) {
139 foreach ($this->fileHandles as $type => $fileHandle) {
140 $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
142 if (isset(
$data[0])) {
143 $this->readBytes[$type] += strlen(
$data);
148 unset($this->fileHandles[$type]);
177 foreach ($this->fileHandles as $handle) {
180 $this->fileHandles = array();
193 $this->files = array();
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
RuntimeException for the Process Component.
write()
Writes input to stdin.
unblock()
Unblocks streams.
WindowsPipes implementation uses temporary files as handles.
__construct($input, $haveReadSupport)
removeFiles()
Removes temporary files.
haveReadSupport()
{Returns if pipes are able to read output.bool}
areOpen()
{Returns if the current state has open file handles or pipes.bool}
getFiles()
{Returns an array of filenames indexed by their related stream in case these pipes use temporary file...
readAndWrite($blocking, $close=false)
{Reads data in file handles and pipes.string[] An array of read data indexed by their fd}
getDescriptors()
{Returns an array of descriptors for the use of proc_open.array}
close()
{{Closes file handles and pipes.}}
Process is a thin wrapper around proc_* functions to easily start independent PHP processes.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file