Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/Symfony/Component/Process/Pipes/WindowsPipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,27 +52,30 @@ public function __construct($input, $haveReadSupport)
Process::STDERR => Process::ERR,
);
$tmpDir = sys_get_temp_dir();
if (!@fopen($file = $tmpDir.'\\sf_proc_00.check', 'wb')) {
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
}
@unlink($file);
$error = '';
set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
for ($i = 0;; ++$i) {
foreach ($pipes as $pipe => $name) {
$file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
if (file_exists($file) && !@unlink($file)) {
if (file_exists($file) && !unlink($file)) {
continue 2;
}
$h = @fopen($file, 'xb');
$h = fopen($file, 'xb');
if (!$h && false === strpos($error, 'File exists')) {
restore_error_handler();
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
}
if (!$h || !$this->fileHandles[$pipe] = fopen($file, 'rb')) {
continue 2;
}
if (isset($this->files[$pipe])) {
@unlink($this->files[$pipe]);
unlink($this->files[$pipe]);
}
$this->files[$pipe] = $file;
}
break;
}
restore_error_handler();
}

parent::__construct($input);
Expand Down