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

[Process] Fix pipes cleaning on Windows #19118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2016

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 2.7
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #19089
License MIT
Doc PR -

@fabpot
Copy link
Member

fabpot commented Jun 20, 2016

I'm sure you are working on a unit test to cover this, right?

@nicolas-grekas nicolas-grekas force-pushed the win-clean branch 2 times, most recently from 9b1b04c to ee3d7d7 Compare June 21, 2016 06:25
@@ -52,9 +52,11 @@ public function __construct($disableOutput, $input)
Process::STDERR => tempnam(sys_get_temp_dir(), 'err_sf_proc'),
);
foreach ($this->files as $offset => $file) {
if (false === $file || false === $this->fileHandles[$offset] = @fopen($file, 'rb')) {
if (false === $file || false === $h = @fopen($file, 'rb')) {
$this->__destruct();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this should work but to me it looks wrong to do it this way. Can't we rather move the code from __destruct() in its own method and reuse that then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's just a method, but anyway: changed

@nicolas-grekas
Copy link
Member Author

Status: needs work

@nicolas-grekas
Copy link
Member Author

Status: needs review

}
for ($i = 0;; ++$i) {
foreach ($pipes as $pipe => $name) {
@unlink($file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't you check whether $this->files[$pipe] is already set, to avoid reopening the same pipe several times in case of a retry when the other one fails ? Or is it done on purpose ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's on purpose: code is simpler, and $i is the name for err & out files for the same process

Copy link
Member

@stof stof Jun 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then, you need to close and unlink files you opened for this iteration in case you move to a retry loop

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, for 3 reasons: rare error condition, simpler code, and the file will be reused on the next run of the process

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fixed as part of other changes to make tests green

@nicolas-grekas nicolas-grekas force-pushed the win-clean branch 8 times, most recently from 2ccb00d to 9ffb895 Compare June 21, 2016 11:21
if (false === $file || false === $this->fileHandles[$offset] = @fopen($file, 'rb')) {
throw new RuntimeException('A temporary file could not be opened to write the process output to, verify that your TEMP environment variable is writable');
$tmpDir = sys_get_temp_dir();
if (!@fopen($file = $tmpDir.'\\sf_proc_00.check', 'wb')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if another process is started at the same time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wb allows it without any issue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright then

@romainneutron
Copy link
Contributor

👍

@romainneutron
Copy link
Contributor

romainneutron commented Jun 21, 2016

Muchas gracias @nicolas-grekas!

@romainneutron romainneutron merged commit d54cd02 into symfony:2.7 Jun 21, 2016
romainneutron added a commit that referenced this pull request Jun 21, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

[Process] Fix pipes cleaning on Windows

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #19089
| License       | MIT
| Doc PR        | -

Commits
-------

d54cd02 [Process] Fix pipes cleaning on Windows
@nicolas-grekas nicolas-grekas deleted the win-clean branch June 21, 2016 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.