Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitad3663a

Browse files
[Process] Fix pipes cleaning on Windows
1 parenta0cdcb0 commitad3663a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,16 @@ public function __construct($disableOutput, $input)
4646
// Fix for PHP bug #51800: reading from STDOUT pipe hangs forever on Windows if the output is too big.
4747
// Workaround for this problem is to use temporary files instead of pipes on Windows platform.
4848
//
49-
// @see https://bugs.php.net/bug.php?id=51800
50-
$this->files =array(
51-
Process::STDOUT =>tempnam(sys_get_temp_dir(),'out_sf_proc'),
52-
Process::STDERR =>tempnam(sys_get_temp_dir(),'err_sf_proc'),
53-
);
54-
foreach ($this->filesas$offset =>$file) {
55-
if (false ===$file ||false ===$this->fileHandles[$offset] = @fopen($file,'rb')) {
49+
// @see https://bugs.php.net/51800
50+
foreach (array(Process::STDOUT, Process::STDERR)as$pipe) {
51+
$file =tempnam(sys_get_temp_dir(),$pipe);
52+
$h =false !==$file ? @fopen($file,'rb') :false;
53+
if (false ===$h) {
54+
$this->close();
5655
thrownewRuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
5756
}
57+
$this->file[$pipe] =$file;
58+
$this->fileHandles[$pipe] =$h;
5859
}
5960
}
6061

@@ -64,7 +65,6 @@ public function __construct($disableOutput, $input)
6465
publicfunction__destruct()
6566
{
6667
$this->close();
67-
$this->removeFiles();
6868
}
6969

7070
/**
@@ -150,6 +150,7 @@ public function close()
150150
fclose($handle);
151151
}
152152
$this->fileHandles =array();
153+
$this->removeFiles();
153154
}
154155

155156
/**
@@ -171,9 +172,7 @@ public static function create(Process $process, $input)
171172
privatefunctionremoveFiles()
172173
{
173174
foreach ($this->filesas$filename) {
174-
if (file_exists($filename)) {
175-
@unlink($filename);
176-
}
175+
@unlink($filename);
177176
}
178177
$this->files =array();
179178
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp