Fix stdio return code handling that has been broken for a few releases.