Backport: Merge pull request #9251 from twadleigh/stdio-hack

Fix #9244