ps_status.h on FreeBSD 4.0 problems and fix

From: Matthew Altus <matt(at)senet(dot)com(dot)au>
To: bugs(at)postgreSQL(dot)org
Subject: ps_status.h on FreeBSD 4.0 problems and fix
Date: 2000-07-07 06:53:30
Message-ID: 39657E6A.49A489E0@senet.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Your name : Matthew Altus
Your email address : matt(at)senet(dot)com(dot)au

System Configuration
---------------------
Architecture : Intel Pentium 3 Dual CPU

Operating System : FreeBSD 4.0 - STABLE

PostgreSQL version : PostgreSQL-6.5.1 (also effects 7.0 as well)

Compiler used : gcc 2.95.2

Please enter a FULL description of your problem:
------------------------------------------------
The ps output of child postgres process doesn't change to display
hostname etc... It displays the same as the postmaster.
I noticed there are links (PS_STATUS marco) from the ps_status to the
lockmgr files, which means it may use this to help determine deadlock
status, which is very bad, as freebsd 4.0 doesn't allow you to write the
argv memory, although I might me completely wrong about this one.

If this problem had already been posted to pgsql-bugs, I couldn't tell
as your seach doesn't work.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------
Install postgres on freeBSD 4.0 and open a connection, type ps axwwwwww
| grep postgres. all children will look the same as the postmaster.

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Below is my replacement to src/include/utils/ps_status.h , you should
place checks for the setproctitle function in the configure script and
use this if its available (most BSD's) instead of overwriting the argv
memory space. You will also need to link against libutil (-lutil).

/*-------------------------------------------------------------------------
*
* ps_status.h
*
* Defines macros to show backend status on the ps status line.
* Unfortunately this is system dpendent.
*
* Below is the FreeBSD version should work FreeBSD 2.2. and
higher.
*
* needs -lutil in makefile/configure script
*
* Written by Matthew Altus
*

*-------------------------------------------------------------------------
*/

#ifndef PS_STATUS_H
#define PS_STATUS_H

#include <sys/types.h>
#include <libutil.h>

extern char ps_status_buffer[];
extern char ps_status[];

#define BUFFERPATHLEN 255

#define PS_DEFINE_BUFFER \
char ps_status_buffer[BUFFERPATHLEN]; \
char ps_status[BUFFERPATHLEN];

#define PS_INIT_STATUS(argc, argv, execname, username, hostname, dbname)
\
{ \
bzero (ps_status_buffer, BUFFERPATHLEN); \
bzero (ps_status, BUFFERPATHLEN); \
sprintf(ps_status_buffer, "%s %s %s %s ", execname,
username, hostname, dbname); \
setproctitle("%s", ps_status_buffer); \
}

#define PS_CLEAR_STATUS() \
{ \
bzero (ps_status, BUFFERPATHLEN); \
setproctitle("%s", ps_status_buffer); \
}

#define PS_SET_STATUS(status) \
{ \
PS_CLEAR_STATUS(); \
strcpy(ps_status, status); \
setproctitle("%s%s", ps_status_buffer, ps_status); \
}

#define PS_STATUS (ps_status)

#endif /* PS_STATUS_H */

--
_____________________________________________________________________
Matthew Altus B.Eng. C.S.E. Sales : (08) 8221 5221
Software Development Engineer Support : (08) 8221 5792
SE Network Access Pty Ltd Fax : (08) 8221 5220
222 Grote Street E-Mail : matt(at)senet(dot)com(dot)au
Adelaide SA 5000 WWW : http://www.senet.com.au

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2000-07-07 07:06:03 Re: [SQL] MAX() of 0 records.
Previous Message Paul McGarry 2000-07-07 05:34:13 Re: [SQL] MAX() of 0 records.