From: | Alexey Klyukin <alexk(at)commandprompt(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | ps buffer is incorrectly padded on the (latest) OS X |
Date: | 2010-09-03 18:19:59 |
Message-ID: | F3E7BC0D-A95D-4C69-8DE6-2743F5F29769@commandprompt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I always wondered why ps ax|grep postgres shows several extra blank lines
after the process name, i.e.
972 ?? Ss 0:00.69 postgres: writer process
973 ?? Ss 0:00.51 postgres: wal writer process
(I put newlines instead of spaces there). By looking into the code I've found
this part of set_ps_display:
#ifdef PS_USE_CLOBBER_ARGV
/* pad unused memory; need only clobber remainder of old status string */
if (last_status_len > ps_buffer_cur_len)
MemSet(ps_buffer + ps_buffer_cur_len, PS_PADDING,
last_status_len - ps_buffer_cur_len);
last_status_len = ps_buffer_cur_len;
#endif /* PS_USE_CLOBBER_ARGV */
PS_PADDING padding on __darwin__ is set to ' '. Apparently this doesn't work
correctly with OS X 10.6. After I changed the define to use '\0' on darwin
extra blank likes (actually consisting of hundreds of spaces without a line
break) disappeared. The one-liner change follows:
===
diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c
index f27a52f..c2ddf33 100644
--- a/src/backend/utils/misc/ps_status.c
+++ b/src/backend/utils/misc/ps_status.c
@@ -76,7 +76,7 @@ bool update_process_title = true;
/* Different systems want the buffer padded differently */
-#if defined(_AIX) || defined(__linux__) || defined(__svr4__)
+#if defined(_AIX) || defined(__linux__) || defined(__svr4__) || defined(__darwin__)
#define PS_PADDING '\0'
#else
#define PS_PADDING ' '
===
I don't have different OS X versions to test, so I'm not sure whether 10.5 or
below are also affected. Also, the patch should specifically check for 10.6,
though I don't know how to distinguish between different OS X versions in
postgres sources (any suggestions?).
Regards,
--
Alexey Klyukin http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2010-09-03 18:34:58 | Re: Windows Tools |
Previous Message | Tom Lane | 2010-09-03 18:16:01 | Re: Interruptible sleeps (was Re: CommitFest 2009-07: Yay, Kevin! Thanks, reviewers!) |