You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (false === $this->fileHandles[Process::STDOUT]) {
52
-
thrownewRuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
thrownewRuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
54
+
}
53
55
}
54
56
$this->readBytes = array(
55
57
Process::STDOUT => 0,
58
+
Process::STDERR => 0,
56
59
);
57
60
}
58
61
}
59
62
60
63
publicfunction__destruct()
61
64
{
62
65
$this->close();
66
+
$this->removeFiles();
63
67
}
64
68
65
69
/**
@@ -105,11 +109,13 @@ public function closeUnixPipes()
105
109
publicfunctiongetDescriptors()
106
110
{
107
111
if ($this->useFiles) {
112
+
// We're not using pipe on Windows platform as it hangs (https://bugs.php.net/bug.php?id=51800)
113
+
// We're not using file handles as it can produce corrupted output https://bugs.php.net/bug.php?id=65650
114
+
// So we redirect output within the commandline and pass the nul device to the process
108
115
returnarray(
109
116
array('pipe', 'r'),
110
-
$this->fileHandles[Process::STDOUT],
111
-
// Use a file handle only for STDOUT. Using for both STDOUT and STDERR would trigger https://bugs.php.net/bug.php?id=65650
112
-
array('pipe', 'w'),
117
+
array('file', 'NUL', 'w'),
118
+
array('file', 'NUL', 'w'),
113
119
);
114
120
}
115
121
@@ -128,6 +134,20 @@ public function getDescriptors()
128
134
);
129
135
}
130
136
137
+
/**
138
+
* Returns an array of filenames indexed by their related stream in case these pipes use temporary files.
139
+
*
140
+
* @return array
141
+
*/
142
+
publicfunctiongetFiles()
143
+
{
144
+
if ($this->useFiles) {
145
+
return$this->files;
146
+
}
147
+
148
+
returnarray();
149
+
}
150
+
131
151
/**
132
152
* Reads data in file handles and pipes.
133
153
*
@@ -322,4 +342,17 @@ private function hasSystemCallBeenInterrupted()
322
342
// stream_select returns false when the `select` system call is interrupted by an incoming signal
323
343
returnisset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call');
0 commit comments