Re: [HACKERS] signed logging format for pid in log_line_prefix?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] signed logging format for pid in log_line_prefix?
Дата
Msg-id 16119.1504278930@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [HACKERS] signed logging format for pid in log_line_prefix?  (Greg Stark <stark@mit.edu>)
Список pgsql-hackers
Greg Stark <stark@mit.edu> writes:
> Both the text and csv logging seem to use %d on for logging the server pid:
> appendStringInfo(buf, "%d", MyProcPid);

> Am I missing something or wouldn't this mean we print pids with large
> values as negative numbers? Isn't that strange? Wouldn't we rather use
> %u here?

pid_t is a signed type; see for example waitpid(2):
      The value of pid can be:
      < -1   meaning  wait  for  any  child process whose process group ID is             equal to the absolute value
ofpid.
 
      -1     meaning wait for any child process.
      0      meaning wait for any child process whose  process  group  ID  is             equal to that of the calling
process.
      > 0    meaning  wait  for  the  child  whose process ID is equal to the             value of pid.

So I think using %d is fine.  Someday we might wish that we were using
a wider type than int to hold PIDs, but I don't think it'll ever be
unsigned.
        regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: [HACKERS] Missing SIZE_MAX
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] signed logging format for pid in log_line_prefix?