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