pg_logging_init() can return ENOTTY with TAP tests

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_logging_init() can return ENOTTY with TAP tests
Date: 2020-09-18 09:57:13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


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

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.


Attachment Content-Type Size
logging-init-errno-v1.patch text/x-diff 414 bytes


Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2020-09-18 10:33:47 Re: Report error position in partition bound check
Previous Message Julien Rouhaud 2020-09-18 09:49:44 Re: [PATCH] Add features to pg_stat_statements