Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] Turn getIterator() args to flags & add ITER_SKIP_OUT/ERR modes #18513

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
Apr 13, 2016

Conversation

nicolas-grekas
Copy link
Member

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

Targeted at 3.1

*
* @throws LogicException in case the output has been disabled
* @throws LogicException In case the process is not started
*
* @return \Generator
*/
public function getIterator($blocking = true, $clearOutput = true)
public function getIterator($flags = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

One of the best advantage of this is to be able to pipe a process in another process.
We could use the same behavior as unix | and forward only stdout (use self:: ITER_SKIP_ERR) by default).

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 good catch, I added a test case chaining two processes, works like a charm!

@@ -1342,6 +1342,21 @@ public function testNonBlockingNorClearingIteratorOutput()
$this->assertSame($expectedOutput, $output);
}

public function testChainedProcesses()
{
$p1 = new Process(self::$phpBin.' -r '.escapeshellarg('fwrite(STDERR, 123); fwrite(STDOUT, 456);'));
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 this use getProcess ?

Copy link
Member Author

Choose a reason for hiding this comment

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

We can have only one getProces per test case. And there is not need to configure differently the process for sigchild. So no need.

Copy link
Member

Choose a reason for hiding this comment

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

Was not aware of getProcess being usable only once per test. so fine with me

@stof
Copy link
Member

stof commented Apr 13, 2016

👍 for this (and should be merged in 3.1 to avoid having to maintain BC for the boolean-based signature as it is a new method in 3.1 anyway)

Status: reviewed

@romainneutron
Copy link
Contributor

👍

@nicolas-grekas nicolas-grekas merged commit 428f12e into symfony:master Apr 13, 2016
nicolas-grekas added a commit that referenced this pull request Apr 13, 2016
…SKIP_OUT/ERR modes (nicolas-grekas)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[Process] Turn getIterator() args to flags & add ITER_SKIP_OUT/ERR modes

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

Targeted at 3.1

Commits
-------

428f12e [Process] Turn getIterator() args to flags & add ITER_SKIP_OUT/ERR modes
@nicolas-grekas nicolas-grekas deleted the proc-flags branch April 13, 2016 13:01
@fabpot fabpot mentioned this pull request May 13, 2016
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.

5 participants