Re: closing file in adjust_data_dir

Поиск
Список
Период
Сортировка
От Ted Yu
Тема Re: closing file in adjust_data_dir
Дата
Msg-id CALte62yKXx8P+=q=_YLNF1tb2Q8KHJwjpUTZzythpyi=skbqxA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: closing file in adjust_data_dir  (Japin Li <japinli@hotmail.com>)
Ответы Re: closing file in adjust_data_dir  (Japin Li <japinli@hotmail.com>)
Список pgsql-hackers


On Tue, Nov 15, 2022 at 6:35 PM Japin Li <japinli@hotmail.com> wrote:

On Wed, 16 Nov 2022 at 10:06, Ted Yu <yuzhihong@gmail.com> wrote:
>> Hi,
> That check is a few line above:
>
> +       if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL)
>         {
>
> Cheers

Thanks for the explanation.  Comment on v2 patch.

        fd = popen(cmd, "r");
-       if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL || pclose(fd) != 0)
+       if (fd == NULL || fgets(filename, sizeof(filename), fd) == NULL)
        {
+               pclose(fd);
                write_stderr(_("%s: could not determine the data directory using command \"%s\"\n"), progname, cmd);
                exit(1);
        }

Here, segfault maybe occurs if fd is NULL.  I think we can remove pclose()
safely since the process will exit.

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

That means we're going back to v1 of the patch.

Cheers 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Slow standby snapshot
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: Allow file inclusion in pg_hba and pg_ident files