Re: [HACKERS] New pg_ctl has retrogressed in error messages

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] New pg_ctl has retrogressed in error messages
Дата
Msg-id 13381.1086050777@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] New pg_ctl has retrogressed in error messages  (Bruce Momjian <pgman@candle.pha.pa.us>)
Ответы Re: [HACKERS] New pg_ctl has retrogressed in error messages  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-patches
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> I also changed all the pid variables to use pid_t.

Good, but ...

> !     fscanf(pidf, "%u", &pid);

this code will fail rather horribly if sizeof(pid_t) != sizeof(int).
Even more to the point, I believe a standalone backend will put
the negative of its PID into the file, and the revised code will fail
to parse that at all.

I think the safest code would be like

    long    tmp;

    fscanf(pidf, "%ld", &tmp);
    if (tmp < 0)
    {
        tmp = -tmp;
        // do anything else needed for backend case
    }
    pid = (pid_t) tmp;


            regards, tom lane

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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] New pg_ctl has retrogressed in error messages
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: [HACKERS] New pg_ctl has retrogressed in error messages