linux: Only set errno after an error