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

Commit85c0c73

Browse files
committed
Fix 'ps' WAIT status display bug on setproctitle() platforms, cleared by
Tom Lane.
1 parent2bea1e0 commit85c0c73

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

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

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* to contain some useful information. Differs wildly across
66
* platforms.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.2 2000/07/09 13:14:11 petere Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.3 2001/03/20 22:31:54 momjian Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* various details abducted from various places
@@ -44,7 +44,7 @@ extern char **environ;
4444
* PS_USE_PS_STRINGS
4545
* assign PS_STRINGS->ps_argvstr = "string"
4646
* (some BSD systems)
47-
*PS_USE_CHANCE_ARGV
47+
*PS_USE_CHANGE_ARGV
4848
* assign argv[0] = "string"
4949
* (some other BSD systems)
5050
* PS_USE_CLOBBER_ARGV
@@ -189,64 +189,68 @@ init_ps_display(int argc, char *argv[],
189189
void
190190
set_ps_display(constchar*value)
191191
{
192+
#ifndefPS_USE_NONE
192193
/* no ps display for stand-alone backend */
193194
if (!IsUnderPostmaster)
194195
return;
195196

196-
#ifndefPS_USE_NONE
197+
# ifdefPS_USE_CLOBBER_ARGV
198+
/* If ps_buffer is a pointer, it might still be null */
197199
if (!ps_buffer)
198200
return;
199-
# ifdefPS_USE_SETPROCTITLE
200-
setproctitle("%s%s",ps_buffer,value);
201+
# endif
201202

202-
# else/*not PS_USE_SETPROCTITLE */
203-
{
204-
size_tvallen=strlen(value);
203+
/*Update ps_buffer to contain both fixed part and value */
204+
StrNCpy(ps_buffer+ps_buffer_fixed_size,value,
205+
ps_buffer_size-ps_buffer_fixed_size);
205206

206-
strncpy(ps_buffer+ps_buffer_fixed_size,value,
207-
ps_buffer_size-ps_buffer_fixed_size);
207+
/* Transmit new setting to kernel, if necessary */
208208

209-
if (ps_buffer_fixed_size+vallen >=ps_buffer_size)
210-
ps_buffer[ps_buffer_size-1]=0;
211-
else
212-
ps_buffer[ps_buffer_fixed_size+vallen]=0;
209+
# ifdefPS_USE_SETPROCTITLE
210+
setproctitle("%s",ps_buffer);
211+
# endif
213212

214-
#ifdefPS_USE_PSTAT
213+
# ifdefPS_USE_PSTAT
215214
{
216215
unionpstunpst;
217216

218217
pst.pst_command=ps_buffer;
219218
pstat(PSTAT_SETCMD,pst,strlen(ps_buffer),0,0);
220219
}
221-
#endif/* PS_USE_PSTAT */
220+
# endif/* PS_USE_PSTAT */
222221

223-
#ifdefPS_USE_PS_STRINGS
222+
# ifdefPS_USE_PS_STRINGS
224223
PS_STRINGS->ps_nargvstr=1;
225224
PS_STRINGS->ps_argvstr=ps_buffer;
226-
#endif/* PS_USE_PS_STRINGS */
225+
# endif/* PS_USE_PS_STRINGS */
227226

228-
#ifdefPS_USE_CLOBBER_ARGV
227+
# ifdefPS_USE_CLOBBER_ARGV
229228
{
230229
char*cp;
231230
/* pad unused memory */
232-
for(cp=ps_buffer+ps_buffer_fixed_size+vallen;
231+
for(cp=ps_buffer+strlen(ps_buffer);
233232
cp<ps_buffer+ps_buffer_size;
234233
cp++)
235234
*cp=PS_PADDING;
236235
}
237-
# endif/* PS_USE_CLOBBER_ARGV */
238-
}
239-
# endif/* not USE_SETPROCTITLE */
236+
# endif/* PS_USE_CLOBBER_ARGV */
237+
240238
#endif/* not PS_USE_NONE */
241239
}
242240

243241

244242
/*
245243
* Returns what's currently in the ps display, in case someone needs
246-
* it.
244+
* it. Note that only the variable part is returned.
247245
*/
248246
constchar*
249247
get_ps_display(void)
250248
{
249+
#ifdefPS_USE_CLOBBER_ARGV
250+
/* If ps_buffer is a pointer, it might still be null */
251+
if (!ps_buffer)
252+
return"";
253+
#endif
254+
251255
returnps_buffer+ps_buffer_fixed_size;
252256
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp