Handle errno and exit status a bit more carefully.