Re: [HACKERS] signed logging format for pid in log_line_prefix?
Alvaro Herrera writes: > I wonder if we could just adopt pid_t for PIDs. We could (if somebody is willing to find and change all the relevant declarations). But that doesn't do anything at all to clarify which printf format code to use for them. Note that the POSIX snippet you quote doesn't actually guarantee that pid_t is not wider than "long". So while we could convert all these places to printf("...%ld...", (long) pid_t_variable_here); that's still not formally correct. Since we have yet to see a platform where our current habit of casting pids to int doesn't work just as well, I'm inclined not to bother changing anything here. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] signed logging format for pid in log_line_prefix?
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 Herrerahttps://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] signed logging format for pid in log_line_prefix?
Greg Stark 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 of pid. -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. > 0meaning 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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
[HACKERS] signed logging format for pid in log_line_prefix?
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? -- greg -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers