|
5 | 5 | * to contain some useful information. Mechanism differs wildly across
|
6 | 6 | * platforms.
|
7 | 7 | *
|
8 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.14 2003/08/04 23:59:39 tgl Exp $ |
| 8 | + * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.15 2003/11/08 19:07:24 tgl Exp $ |
9 | 9 | *
|
10 | 10 | * Copyright (c) 2000-2003, PostgreSQL Global Development Group
|
11 | 11 | * various details abducted from various places
|
@@ -57,7 +57,7 @@ extern char **environ;
|
57 | 57 | #define PS_USE_PSTAT
|
58 | 58 | #elif defined(HAVE_PS_STRINGS)
|
59 | 59 | #define PS_USE_PS_STRINGS
|
60 |
| -#elif defined(BSD) || defined(__bsdi__) || defined(__hurd__) |
| 60 | +#elif (defined(BSD) || defined(__bsdi__) || defined(__hurd__)) && !defined(__darwin__) |
61 | 61 | #define PS_USE_CHANGE_ARGV
|
62 | 62 | #elif defined(__linux__) || defined(_AIX) || defined(__sgi) || (defined(sun) && !defined(BSD)) || defined(ultrix) || defined(__ksr__) || defined(__osf__) || defined(__QNX__) || defined(__svr4__) || defined(__svr5__) || defined(__darwin__)
|
63 | 63 | #define PS_USE_CLOBBER_ARGV
|
@@ -143,7 +143,7 @@ save_ps_display_args(int argc, char *argv[])
|
143 | 143 | }
|
144 | 144 |
|
145 | 145 | ps_buffer = argv[0];
|
146 |
| - ps_buffer_size = end_of_area - argv[0] - 1; |
| 146 | + ps_buffer_size = end_of_area - argv[0]; |
147 | 147 |
|
148 | 148 | /*
|
149 | 149 | * move the environment out of the way
|
@@ -193,7 +193,13 @@ init_ps_display(const char *username, const char *dbname,
|
193 | 193 | #endif /* PS_USE_CHANGE_ARGV */
|
194 | 194 |
|
195 | 195 | #ifdef PS_USE_CLOBBER_ARGV
|
196 |
| - save_argv[1] = NULL; |
| 196 | + { |
| 197 | + int i; |
| 198 | + |
| 199 | + /* make extra argv slots point at end_of_area (a NUL) */ |
| 200 | + for (i = 1; i < save_argc; i++) |
| 201 | + save_argv[i] = ps_buffer + ps_buffer_size; |
| 202 | + } |
197 | 203 | #endif /* PS_USE_CLOBBER_ARGV */
|
198 | 204 |
|
199 | 205 | /*
|
|
0 commit comments