This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 94aacec717 merged branch romainneutron/StreamSelect (PR #6540)
This PR was merged into the 2.1 branch.

Commits
-------

fa6fb6f [Process] Do not reset stdout/stderr pipes on Interrupted system call

Discussion
----------

[Process][2.1] Do not reset stdout/stderr pipes on stream_select failure

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT

When `stream_select` is called and failed, pipes are currently reset to an empty array. As a result, both error-output and output are empty whereas the exitcode is 0 (successful process).

There is no reason (at least I don't see it) to reset pipes when an error occurs.

---------------------------------------------------------------------------

by fabpot at 2013-01-04T08:18:03Z

This behavior was introduced by @Seldaek in bcf8cf91. Any reason?

---------------------------------------------------------------------------

by Seldaek at 2013-01-04T17:22:33Z

The rationale was that if stream_select failed, it will fail every time (maybe this is an incorrect assumption and I introduced a bug there). Since the while loop checks for $this->pipes being not empty, if the process dies off and stream_select() starts failing, it will be stuck in the while loop forever. That's what I was fixing there. As far as I can tell, your fix reintroduces that problem. Can you explain a bit more what you mean by "error-output and output are empty"? Maybe adding a test for the case you are seeing would help too?

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T17:47:00Z

Hi !

I'm actually using `Process` in a amqp client using PhpAmqpLib. Sometimes both output and error-output of a process are empty whereas the process returned with an exitcode equal to 0.

By *empty*, I mean that the output of both `$process->getOuptut()` and `$process->getErrorOuptut()` are equal to `''`.

I removed the `@` before the `stream_select` and realized that some calls where failing :

```
stream_select(): unable to select [4]: Interrupted system call (max_fd=13) in .../vendor/symfony/process/Symfony/Component/Process/Process.php on line 341
```

With my patch, it appears that if a `stream_select` call fails one time, it can be called with success a second time.

Adding a test case that triggers this error does not seem easy as it seems system related.

What do you think about it ?

---------------------------------------------------------------------------

by Seldaek at 2013-01-04T17:52:04Z

Ok I see. So I guess your fix makes sense since stream_select can fail legitimately, but it's not the whole story. If it fails because the process died off (or whatever the cause was on windows) we shouldn't keep trying forever. Maybe just adding a limit of N retries that is reset whenever a call succeeds would be enough to go over the odd system call being interrupted without allowing infinite loops. Not sure what N makes sense.

---------------------------------------------------------------------------

by igorw at 2013-01-04T17:53:45Z

As per the `stream_select` manpage it can return false when interrupted by a system call. That does not indicate that something is broken. However, I'm not sure if it is possible to distinguish between actual errors and interrupts without capturing and parsing the error message.

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T18:50:56Z

I've updated the PR to consider the error message as it's currently the only solution to find out why `stream_select` failed

---------------------------------------------------------------------------

by romainneutron at 2013-01-04T18:59:15Z

Merged fixes suggested by @stloyd  and @Seldaek
2013-01-04 22:46:41 +01:00
src/Symfony merged branch romainneutron/StreamSelect (PR #6540) 2013-01-04 22:46:41 +01:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore ignore composer.phar 2012-04-20 14:10:06 +01:00
.travis.yml forced Travis to use source to workaround their not-up-to-date Composer on PHP 5.3.3 2012-11-13 15:04:20 +01:00
autoload.php.dist Removed the unnecessary file include 2012-08-31 13:16:54 +02:00
CHANGELOG-2.0.md updated CHANGELOG for 2.0.21 2012-12-21 11:10:50 +01:00
CHANGELOG-2.1.md updated CHANGELOG for 2.1.6 2012-12-21 11:24:34 +01:00
composer.json Removed useless branch alias for dev-master in composer.json 2012-12-06 11:00:55 +01:00
CONTRIBUTING.md Making it easier to grab the PR template. 2012-12-15 21:57:27 +00:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.0.20 2012-12-20 08:50:28 +01:00
LICENSE updated license year 2013-01-04 17:59:43 +01:00
phpunit.xml.dist [Locale] fixed tests 2012-12-05 14:13:56 +01:00
README.md Merge branch '2.0' into 2.1 2012-12-20 08:21:29 +01:00
UPGRADE-2.1.md info about session namespace 2012-11-19 17:25:14 +01:00

README

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.3 and up.

Be warned that PHP versions before 5.3.8 are known to be buggy and might not work for you:

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.

Running Symfony2 Tests

Information on how to run the Symfony2 test suite can be found in the Running Symfony2 Tests section.