From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Check return value of pclose() correctly
Date: Tue, 15 Nov 2022 14:42:44 +0000
Message-ID: <E1oux99-000Jw3-OT@gemulon.postgresql.org> (raw)
Check return value of pclose() correctly
Some callers didn't check the return value of pclose() or
ClosePipeStream() correctly. Either they didn't check it at all or
they treated it like the return of fclose().
The correct way is to first check whether the return value is -1, and
then report errno, and then check the return value like a result from
system(), for which we already have wait_result_to_str() to make it
simpler. To make this more compact, expand wait_result_to_str() to
also handle -1 explicitly.
Reviewed-by: Ankit Kumar Pandey <itsankitkp@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/8cd9fb02-bc26-65f1-a809-b1cb360eef73@enterprisedb.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2fe3bdbd691a5d11626308e7d660440be6c210c8
Modified Files
--------------
src/backend/commands/collationcmds.c | 11 ++++++++++-
src/bin/pg_ctl/pg_ctl.c | 3 +--
src/bin/pg_upgrade/controldata.c | 12 +++++++++---
src/bin/pg_upgrade/exec.c | 6 +++++-
src/bin/pg_upgrade/option.c | 6 +++++-
src/bin/pgbench/pgbench.c | 2 +-
src/bin/psql/command.c | 18 ++++++++++++++----
src/common/wait_error.c | 14 ++++++++++++--
8 files changed, 57 insertions(+), 15 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: peter@eisentraut.org
Subject: Re: pgsql: Check return value of pclose() correctly
In-Reply-To: <E1oux99-000Jw3-OT@gemulon.postgresql.org>
References: <E1oux99-000Jw3-OT@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox