-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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
Conversation
c717d73
to
8399b79
Compare
* | ||
* @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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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!
8399b79
to
04e8f0a
Compare
04e8f0a
to
428f12e
Compare
@@ -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);')); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
👍 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 |
👍 |
…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
Targeted at 3.1