Michael Paquier <michael@paquier.xyz> writes:
> Some system calls may not set errno even if they succeed, like
> strtol() on Linux for example, so in this case it can cause option
> handling to fail because of the error set by logging initialization.
> Shouldn't we reset errno to 0 once logging initialization is done? It
> seems to me that this code path should finish with a clean sheet, and
> attached is a proposal of patch to address this issue.
No, this is a bad idea. The right place to fix this is whatever code
segment is relying on errno to be initially zero; that is NEVER a sane
assumption. That is, a valid coding pattern is something like
errno = 0;
strtol(...);
if (errno) ...
regards, tom lane