Re: signed logging format for pid in log_line_prefix?

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: signed logging format for pid in log_line_prefix?
Date: 2017-09-01 15:17:41
Message-ID: 20170901151741.ivjm37ouy3zovkdz@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark wrote:
> 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?

MyProcPid is an int, so %d is the natural choice. the sys_types.h
manpage says:

* blksize_t, pid_t, and ssize_t shall be signed integer types.

and also:
The implementation shall support one or more programming environments
in which the widths of blksize_t, pid_t, size_t, ssize_t, and susec‐
onds_t are no greater than the width of type long.

I wonder if we could just adopt pid_t for PIDs.

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-09-01 15:47:25 Re: Speed up Clog Access by increasing CLOG buffers
Previous Message Tom Lane 2017-09-01 15:15:30 Re: signed logging format for pid in log_line_prefix?