Re: ps display
I have applied this patch that Tom Lane and I worked on to fix the
display of WAIT status on setproctitle() displays.
Without the patch, on setproctitle() machines, the ps display was
truncated when waiting on a lock.
Here is an extended version of your patch that cleans things up some
more (uses StrNCpy, for example). I've checked the USE_PSTAT and
USE_CLOBBER_ARGV paths.regards, tom lane
*** src/backend/utils/misc/ps_status.c.orig Sat Feb 17 17:34:26 2001 --- src/backend/utils/misc/ps_status.c Tue Mar 20 17:02:03 2001 *************** *** 44,50 **** * PS_USE_PS_STRINGS * assign PS_STRINGS->ps_argvstr = "string" * (some BSD systems) ! * PS_USE_CHANCE_ARGV * assign argv[0] = "string" * (some other BSD systems) * PS_USE_CLOBBER_ARGV --- 44,50 ---- * PS_USE_PS_STRINGS * assign PS_STRINGS->ps_argvstr = "string" * (some BSD systems) ! * PS_USE_CHANGE_ARGV * assign argv[0] = "string" * (some other BSD systems) * PS_USE_CLOBBER_ARGV *************** *** 189,252 **** void set_ps_display(const char * value) { /* no ps display for stand-alone backend */ if (!IsUnderPostmaster) return;! #ifndef PS_USE_NONE
if (!ps_buffer)
return;
! # ifdef PS_USE_SETPROCTITLE
! setproctitle("%s%s", ps_buffer, value);! # else /* not PS_USE_SETPROCTITLE */
! {
! size_t vallen = strlen(value);! strncpy(ps_buffer + ps_buffer_fixed_size, value,
! ps_buffer_size - ps_buffer_fixed_size);! if (ps_buffer_fixed_size + vallen >= ps_buffer_size)
! ps_buffer[ps_buffer_size - 1] = 0;
! else
! ps_buffer[ps_buffer_fixed_size + vallen] = 0;! # ifdef PS_USE_PSTAT
{
union pstun pst;pst.pst_command = ps_buffer;
pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0);
}
! # endif /* PS_USE_PSTAT */! # ifdef PS_USE_PS_STRINGS
PS_STRINGS->ps_nargvstr = 1;
PS_STRINGS->ps_argvstr = ps_buffer;
! # endif /* PS_USE_PS_STRINGS */! # ifdef PS_USE_CLOBBER_ARGV
{
char * cp;
/* pad unused memory */
! for(cp = ps_buffer + ps_buffer_fixed_size + vallen;
cp < ps_buffer + ps_buffer_size;
cp++)
*cp = PS_PADDING;
}
! # endif /* PS_USE_CLOBBER_ARGV */
! }
! # endif /* not USE_SETPROCTITLE */
#endif /* not PS_USE_NONE */
}/* * Returns what's currently in the ps display, in case someone needs ! * it. */ const char * get_ps_display(void) { return ps_buffer + ps_buffer_fixed_size; } --- 189,256 ---- void set_ps_display(const char * value) { + #ifndef PS_USE_NONE /* no ps display for stand-alone backend */ if (!IsUnderPostmaster) return;! # ifdef PS_USE_CLOBBER_ARGV
! /* If ps_buffer is a pointer, it might still be null */
if (!ps_buffer)
return;
! # endif! /* Update ps_buffer to contain both fixed part and value */
! StrNCpy(ps_buffer + ps_buffer_fixed_size, value,
! ps_buffer_size - ps_buffer_fixed_size);! /* Transmit new setting to kernel, if necessary */
! # ifdef PS_USE_SETPROCTITLE
! setproctitle("%s", ps_buffer);
! # endif! # ifdef PS_USE_PSTAT
{
union pstun pst;pst.pst_command = ps_buffer;
pstat(PSTAT_SETCMD, pst, strlen(ps_buffer), 0, 0);
}
! # endif /* PS_USE_PSTAT */! # ifdef PS_USE_PS_STRINGS
PS_STRINGS->ps_nargvstr = 1;
PS_STRINGS->ps_argvstr = ps_buffer;
! # endif /* PS_USE_PS_STRINGS */! # ifdef PS_USE_CLOBBER_ARGV
{
char * cp;
/* pad unused memory */
! for(cp = ps_buffer + strlen(ps_buffer);
cp < ps_buffer + ps_buffer_size;
cp++)
*cp = PS_PADDING;
}
! # endif /* PS_USE_CLOBBER_ARGV */
!
#endif /* not PS_USE_NONE */
}/* * Returns what's currently in the ps display, in case someone needs ! * it. Note that only the variable part is returned. */ const char * get_ps_display(void) { + #ifdef PS_USE_CLOBBER_ARGV + /* If ps_buffer is a pointer, it might still be null */ + if (!ps_buffer) + return ""; + #endif + return ps_buffer + ps_buffer_fixed_size; }
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Import Notes
Reply to msg id not found: 13397.985126482@sss.pgh.pa.us