Title: proc_open mixed up stderr and stdout when using pty for pipe · Issue #17983 · php/php-src · GitHub
Open Graph Title: proc_open mixed up stderr and stdout when using pty for pipe · Issue #17983 · php/php-src
X Title: proc_open mixed up stderr and stdout when using pty for pipe · Issue #17983 · php/php-src
Description: Description We were having randomly bug in our ci where sometimes some test would failed because the stdout of a sub process launched by php was not complete. We manage to make a reproducer, and it seems that sometimes stdout output woul...
Open Graph Description: Description We were having randomly bug in our ci where sometimes some test would failed because the stdout of a sub process launched by php was not complete. We manage to make a reproducer, and it...
X Description: Description We were having randomly bug in our ci where sometimes some test would failed because the stdout of a sub process launched by php was not complete. We manage to make a reproducer, and it...
Opengraph URL: https://github.com/php/php-src/issues/17983
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"proc_open mixed up stderr and stdout when using pty for pipe","articleBody":"### Description\n\nWe were having randomly bug in our ci where sometimes some test would failed because the stdout of a sub process launched by php was not complete.\n\nWe manage to make a reproducer, and it seems that sometimes stdout output would go to stderr.\n\nHere is a reproducer : \n\n```php\n\u003c?php\n\n[$reference] = run_process();\n\necho \"Output Reference:\\n\";\necho $reference;\necho \"\\n\";\n\nfor ($i=0; $i \u003c 10_000; $i++) {\n if ($i > 0 && $i % 80 === 0) {\n echo \"\\n\";\n }\n echo '.';\n [$output, $error] = run_process();\n\n // uncomment this line to make it works\n// $output .= $error;\n\n \n if ($output !== $reference) {\n throw new \\RuntimeException(\"Output mismatch\");\n }\n}\n\nfunction run_process(){\n $descriptors = [\n ['pty'],\n ['pty'],\n ['pty'],\n ];\n $pipes = [];\n\n $proc = proc_open(['cat', __FILE__], $descriptors, $pipes);\n $output = \"\";\n $error = \"\";\n\n stream_set_blocking($pipes[1], 0);\n stream_set_blocking($pipes[2], 0);\n\n while (proc_get_status($proc)['running']) {\n usleep(10); // longer timer will not cause the issue\n\n $output .= @stream_get_contents($pipes[1], -1);\n $error .= @stream_get_contents($pipes[2], -1);\n }\n\n $output .= @stream_get_contents($pipes[1], -1);\n $error .= @stream_get_contents($pipes[2], -1);\n\n return [$output, $error];\n}\n\n```\n\nI suspect this have to do about having a pipe not ready or something mixed, having a longer timer before first read, reduce a lot the probability of error\n\nSee also https://github.com/symfony/symfony/issues/59927\n\n\n### PHP Version\n\nPHP 8.4\n\n### Operating System\n\n_No response_","author":{"url":"https://github.com/joelwurtz","@type":"Person","name":"joelwurtz"},"datePublished":"2025-03-06T17:45:41Z","url":"https://github.com/php/php-src/issues/17983"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:17f5b75a-3c2e-7d6f-09ad-eb97a583d588 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 946A:7C906:1088EE3:168BAED:6B055CAC |
| html-safe-nonce | 18a159d40e1684fe5a8e80bf0cb4611786734f5e524dc18ef9934844e629d767 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NDZBOjdDOTA2OjEwODhFRTM6MTY4QkFFRDo2QjA1NUNBQyIsInZpc2l0b3JfaWQiOiI2MDYwMzE0OTcwODkyMzYwODc2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 002035885b9921d8cb40b8e43812d5d6758fdaf2eacc7bbb7e7b04970ea39ad9 |
| hovercard-subject-tag | issue:2901050332 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/php/php-src/17983/issue_layout |
| twitter:image | https://opengraph.githubassets.com/68db0600baed1b2f5a573b4fe1e4f447bc7a72cfdd5853135e90cf1d9fb53d80/php/php-src/issues/17983 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/68db0600baed1b2f5a573b4fe1e4f447bc7a72cfdd5853135e90cf1d9fb53d80/php/php-src/issues/17983 |
| og:image:alt | Description We were having randomly bug in our ci where sometimes some test would failed because the stdout of a sub process launched by php was not complete. We manage to make a reproducer, and it... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | joelwurtz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 8a6760da3cce5e2d079d07e3b62df71194316c4478db1a5e38050f44fce72c72 |
| turbo-cache-control | no-preview |
| go-import | github.com/php/php-src git https://github.com/php/php-src.git |
| octolytics-dimension-user_id | 25158 |
| octolytics-dimension-user_login | php |
| octolytics-dimension-repository_id | 1903522 |
| octolytics-dimension-repository_nwo | php/php-src |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1903522 |
| octolytics-dimension-repository_network_root_nwo | php/php-src |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8327739ac0648b9c3c722b5f401f7338553936b8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width