closing file in adjust_data_dir

From: Ted Yu <yuzhihong(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: closing file in adjust_data_dir
Date: 2022-11-15 18:43:51
Message-ID: CALte62y3yZpHNFnYVz1uACaFbmb6go9fyeRaO5uHF5XaxtarbA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,
I was looking at the commit:

commit 2fe3bdbd691a5d11626308e7d660440be6c210c8
Author: Peter Eisentraut <peter(at)eisentraut(dot)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 Content-Type Size
pg-ctl-close-fd.patch application/octet-stream 736 bytes

Responses

Browse pgsql-hackers by date

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