Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cf43e63

Browse filesBrowse files
[Process] Fix write access check for pipes on Windows
1 parent c4069a4 commit cf43e63
Copy full SHA for cf43e63

File tree

1 file changed

+10
-7
lines changed
Filter options

1 file changed

+10
-7
lines changed

‎src/Symfony/Component/Process/Pipes/WindowsPipes.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Process/Pipes/WindowsPipes.php
+10-7Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,30 @@ public function __construct($disableOutput, $input)
5252
Process::STDERR => Process::ERR,
5353
);
5454
$tmpDir = sys_get_temp_dir();
55-
if (!@fopen($file = $tmpDir.'\\sf_proc_00.check', 'wb')) {
56-
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
57-
}
58-
@unlink($file);
55+
$error = '';
56+
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
5957
for ($i = 0;; ++$i) {
6058
foreach ($pipes as $pipe => $name) {
6159
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
62-
if (file_exists($file) && !@unlink($file)) {
60+
if (file_exists($file) && !unlink($file)) {
6361
continue 2;
6462
}
65-
$h = @fopen($file, 'xb');
63+
$h = fopen($file, 'xb');
64+
if (!$h && false === strpos($error, 'File exists')) {
65+
restore_error_handler();
66+
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
67+
}
6668
if (!$h || !$this->fileHandles[$pipe] = fopen($file, 'rb')) {
6769
continue 2;
6870
}
6971
if (isset($this->files[$pipe])) {
70-
@unlink($this->files[$pipe]);
72+
unlink($this->files[$pipe]);
7173
}
7274
$this->files[$pipe] = $file;
7375
}
7476
break;
7577
}
78+
restore_error_handler();
7679
}
7780

7881
parent::__construct($input);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.