And that's a general truism for errno. It only gets assigned if an error occurs. So it you ever want to test errno for success you have to set it to 0 before the call, because the call won't set errno in the success path of the call.