closing file in adjust_data_dir - Mailing list pgsql-hackers

From Ted Yu
Subject closing file in adjust_data_dir
Date
Msg-id CALte62y3yZpHNFnYVz1uACaFbmb6go9fyeRaO5uHF5XaxtarbA@mail.gmail.com
Whole thread Raw
Responses Re: closing file in adjust_data_dir
Re: closing file in adjust_data_dir
List pgsql-hackers
Hi,
I was looking at the commit:

commit 2fe3bdbd691a5d11626308e7d660440be6c210c8
Author: Peter Eisentraut <peter@eisentraut.org>
Date:   Tue Nov 15 15:35:37 2022 +0100

    Check return value of pclose() correctly

In src/bin/pg_ctl/pg_ctl.c :

    if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL || pclose(fd) != 0)

If the fgets() call doesn't return NULL, the pclose() would be skipped.
Since the original pclose() call was removed, wouldn't this lead to fd leaking ?

Please see attached patch for my proposal.

Cheers
Attachment

pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Reducing the WAL overhead of freezing in VACUUM by deduplicating per-tuple freeze plans
Next
From: Ankit Kumar Pandey
Date:
Subject: Distinct tightly coupled with Agg