8000 bug #19579 [Process] Strengthen Windows pipe files opening (again...)… · symfony/symfony@6f10550 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f10550

Browse files
committed
bug #19579 [Process] Strengthen Windows pipe files opening (again...) (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [Process] Strengthen Windows pipe files opening (again...) | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #19336 | License | MIT | Doc PR | - A nightmare... See https://ci.appveyor.com/project/fabpot/symfony/build/1.0.11427#L965 Commits ------- a7a2d16 [Process] Strengthen Windows pipe files opening (again...)
2 parents 5d467ef + a7a2d16 commit 6f10550

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,22 @@ public function __construct($disableOutput, $input)
5151
Process::STDOUT => Process::OUT,
5252
Process::STDERR => Process::ERR,
5353
);
54+
$tmpCheck = false;
5455
$tmpDir = sys_get_temp_dir();
55-
$error = 'unknown reason';
56-
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
56+
$lastError = 'unknown reason';
57+
set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
5758
for ($i = 0;; ++$i) {
5859
foreach ($pipes as $pipe => $name) {
5960
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
6061
if (file_exists($file) && !unlink($file)) {
6162
continue 2;
6263
}
6364
$h = fopen($file, 'xb');
64-
if (!$h && false === strpos($error, 'File exists& 6537 #39;)) {
65+
if (!$h) {
66+
$error = $lastError;
67+
if ($tmpCheck || $tmpCheck = unlink(tempnam(false, 'sf_check_'))) {
68+
continue;
69+
}
6570
restore_error_handler();
6671
throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $error));
6772
}

0 commit comments

Comments
 (0)
0