save errno earlier so it does not get cleared, see #6