Merge "Fix errno handling to avoid being overwritten"