|
5 | 5 | * to contain some useful information. Mechanism differs wildly across
|
6 | 6 | * platforms.
|
7 | 7 | *
|
8 |
| - * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.21 2004/08/29 05:06:51 momjian Exp $ |
| 8 | + * $PostgreSQL: pgsql/src/backend/utils/misc/ps_status.c,v 1.22 2004/12/02 22:28:22 momjian Exp $ |
9 | 9 | *
|
10 | 10 | * Copyright (c) 2000-2004, PostgreSQL Global Development Group
|
11 | 11 | * various details abducted from various places
|
@@ -65,6 +65,8 @@ extern char **environ;
|
65 | 65 | #define PS_USE_CHANGE_ARGV
|
66 | 66 | #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__)
|
67 | 67 | #define PS_USE_CLOBBER_ARGV
|
| 68 | +#elif defined (WIN32) |
| 69 | +#define PS_USE_WIN32 |
68 | 70 | #else
|
69 | 71 | #define PS_USE_NONE
|
70 | 72 | #endif
|
@@ -95,6 +97,28 @@ static size_t ps_buffer_fixed_size; /* size of the constant prefix */
|
95 | 97 | static int save_argc;
|
96 | 98 | static char **save_argv;
|
97 | 99 |
|
| 100 | +#ifdef WIN32 |
| 101 | + /* |
| 102 | + * Win32 does not support showing any changed arguments. To make it |
| 103 | + * at all possible to track which backend is doing what, we create |
| 104 | + * a named object that can be viewed with for example Process Explorer |
| 105 | + */ |
| 106 | +static HANDLE ident_handle = INVALID_HANDLE_VALUE; |
| 107 | +static void pgwin32_update_ident(char *ident) |
| 108 | +{ |
| 109 | + char name[PS_BUFFER_SIZE+32]; |
| 110 | + |
| 111 | + if (ident_handle != INVALID_HANDLE_VALUE) |
| 112 | + CloseHandle(ident_handle); |
| 113 | + |
| 114 | + sprintf(name,"pgident: %s",ident); |
| 115 | + |
| 116 | + ident_handle = CreateEvent(NULL, |
| 117 | + TRUE, |
| 118 | + FALSE, |
| 119 | + name); |
| 120 | +} |
| 121 | +#endif |
98 | 122 |
|
99 | 123 | /*
|
100 | 124 | * Call this early in startup to save the original argc/argv values.
|
@@ -267,6 +291,11 @@ init_ps_display(const char *username, const char *dbname,
|
267 | 291 | #endif
|
268 | 292 |
|
269 | 293 | ps_buffer_fixed_size = strlen(ps_buffer);
|
| 294 | + |
| 295 | +#ifdef WIN32 |
| 296 | + pgwin32_update_ident(ps_buffer); |
| 297 | +#endif |
| 298 | + |
270 | 299 | #endif /* not PS_USE_NONE */
|
271 | 300 | }
|
272 | 301 |
|
@@ -327,6 +356,11 @@ set_ps_display(const char *activity)
|
327 | 356 | MemSet(ps_buffer + buflen, PS_PADDING, ps_buffer_size - buflen);
|
328 | 357 | }
|
329 | 358 | #endif /* PS_USE_CLOBBER_ARGV */
|
| 359 | + |
| 360 | +#ifdef WIN32 |
| 361 | + pgwin32_update_ident(ps_buffer); |
| 362 | +#endif |
| 363 | + |
330 | 364 | #endif /* not PS_USE_NONE */
|
331 | 365 | }
|
332 | 366 |
|
|
0 commit comments