pg_logging_init() can return ENOTTY with TAP tests - Mailing list pgsql-hackers

From Michael Paquier
Subject pg_logging_init() can return ENOTTY with TAP tests
Date
Msg-id 20200918095713.GA20887@paquier.xyz
Whole thread Raw
Responses Re: pg_logging_init() can return ENOTTY with TAP tests  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hi,

While hacking my way around a different patch (better option handling
for pg_test_fsync), I got surprised by the fact that if we run the TAP
tests, logging initialization could return with errno set to ENOTTY
because we call isatty() to check for output coloring.  I found that
this can be possible with Debian gid that uses a recent version of
IPC::Run.

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.

Thoughts?
--
Michael

Attachment

pgsql-hackers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: [PATCH] Add features to pg_stat_statements
Next
From: Ashutosh Bapat
Date:
Subject: Re: Report error position in partition bound check