Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit917c8bb

Browse files
committed
On win32, there is currently no way to get the equivalent function of
the "ps" argument list on Unix - meaning that there is no way toidentify for example the stats processors or the bgwriter.This patch adds this functionality, in a bit of a crufty way. It createsa kernel Event object with the name of what would be in the title. Thiscan be viewed using for example Process Explorer.It's been very handy for me during both debugging and using. I haven'tfigured a better way, but perhaps someone has one that's less crufty? Ifnot, here is at least a working patch :-)Magnus Hagander
1 parent1646586 commit917c8bb

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

‎src/backend/utils/misc/ps_status.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* to contain some useful information. Mechanism differs wildly across
66
* platforms.
77
*
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 $
99
*
1010
* Copyright (c) 2000-2004, PostgreSQL Global Development Group
1111
* various details abducted from various places
@@ -65,6 +65,8 @@ extern char **environ;
6565
#definePS_USE_CHANGE_ARGV
6666
#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__)
6767
#definePS_USE_CLOBBER_ARGV
68+
#elif defined (WIN32)
69+
#definePS_USE_WIN32
6870
#else
6971
#definePS_USE_NONE
7072
#endif
@@ -95,6 +97,28 @@ static size_t ps_buffer_fixed_size;/* size of the constant prefix */
9597
staticintsave_argc;
9698
staticchar**save_argv;
9799

100+
#ifdefWIN32
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+
staticHANDLEident_handle=INVALID_HANDLE_VALUE;
107+
staticvoidpgwin32_update_ident(char*ident)
108+
{
109+
charname[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
98122

99123
/*
100124
* 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,
267291
#endif
268292

269293
ps_buffer_fixed_size=strlen(ps_buffer);
294+
295+
#ifdefWIN32
296+
pgwin32_update_ident(ps_buffer);
297+
#endif
298+
270299
#endif/* not PS_USE_NONE */
271300
}
272301

@@ -327,6 +356,11 @@ set_ps_display(const char *activity)
327356
MemSet(ps_buffer+buflen,PS_PADDING,ps_buffer_size-buflen);
328357
}
329358
#endif/* PS_USE_CLOBBER_ARGV */
359+
360+
#ifdefWIN32
361+
pgwin32_update_ident(ps_buffer);
362+
#endif
363+
330364
#endif/* not PS_USE_NONE */
331365
}
332366

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp