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

[Process] Use a pipe for stderr in pty mode to avoid mixed output between stdout and stderr#59949

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

joelwurtz
Copy link
Contributor

@joelwurtzjoelwurtz commentedMar 10, 2025
edited
Loading

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#59927
LicenseMIT

This PR split the stderr in a pipe to correctly split stdout / stderr when using->setPty

When usingpty for pipes, PHP will only open only one pty and share the "same" fd for all pipes (it use dup but the original fd is the same)

Which means there is a possibility than stdout goes to stderr (or vice versa) when usingpty for both stdout and stderr.

I did not make a test as this behavior is erratic and happens under other conditions that are hard to find (see related issue to see reproducer, we have to do some iterations before it happens)

Copy link
Contributor

@OskarStarkOskarStark left a comment
edited
Loading

Choose a reason for hiding this comment

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

Can you please add a test case or is it hard to achieve?

Was written in den PR header

@OskarStarkOskarStark changed the titlefix(process): use a pipe for stderr in pty mode to avoid mixed output…fix(process): use a pipe for stderr in pty mode to avoid mixed output between stdout and stderrMar 10, 2025
@joelwurtz
Copy link
ContributorAuthor

Like i said, test is hard to achieve it happens randomly our reproducer for this is the current script :

<?phprequire'vendor/autoload.php';useSymfony\Component\Process\Process;$reference =run_process();echo"Output Reference:\n";echo$reference;echo"\n";for ($i=0;$i <100_000;$i++) {if ($i >0 &&$i %80 ===0) {echo"\n";    }echo'.';$output =run_process();if ($output !==$reference) {echo"\n!!Output changed!!\n";echo"New output:\n";echo"$output\n";exit(1);    }}functionrun_process(){$process =newProcess(['cat',__FILE__]);// If you comment the following line, the test become stable$process->setPty(true);$process->mustRun();return$process->getOutput();}
OskarStark reacted with thumbs up emoji

@joelwurtzjoelwurtzforce-pushed thefix/fix-mixed-stdout-stderr branch 2 times, most recently fromf6b1b56 to001b418CompareMarch 10, 2025 16:57
@joelwurtz
Copy link
ContributorAuthor

I spoke to soon, i added a test, before this change everything was in thegetOutput

OskarStark reacted with heart emoji

@joelwurtz
Copy link
ContributorAuthor

Failed test seems to not be related, so ready for review i guess

@carsonbotcarsonbot changed the titlefix(process): use a pipe for stderr in pty mode to avoid mixed output between stdout and stderr[Process] fix(process): use a pipe for stderr in pty mode to avoid mixed output between stdout and stderrMar 13, 2025
@nicolas-grekasnicolas-grekas changed the title[Process] fix(process): use a pipe for stderr in pty mode to avoid mixed output between stdout and stderr[Process] Use a pipe for stderr in pty mode to avoid mixed output between stdout and stderrMar 13, 2025
@nicolas-grekas
Copy link
Member

Good catch, thanks@joelwurtz.

@nicolas-grekasnicolas-grekas merged commitbb07d18 intosymfony:6.4Mar 13, 2025
10 of 11 checks passed
@joelwurtzjoelwurtz deleted the fix/fix-mixed-stdout-stderr branchMarch 21, 2025 09:23
This was referencedMar 28, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@OskarStarkOskarStarkOskarStark left review comments

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

4 participants
@joelwurtz@nicolas-grekas@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp