pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
setproctitle() no longer used?
20+ messages / 4 participants
[nested] [flat]

* setproctitle() no longer used?
@ 2000-05-10 11:57 The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 20+ messages in thread

From: The Hermit Hacker @ 2000-05-10 11:57 UTC (permalink / raw)
  To: pgsql-hackers


Well, that would explain that, now, wouldn't it?  did we remove this
somewhere along the way? *raised eyebrow*

pgsql% find . -name "*.[ch]" -exec grep setproctitle {} \; -print
pgsql% pwd
/pgsql/src/pgsql/src
pgsql% 


Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 




^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
@ 2000-05-10 21:25 ` Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 21:35   ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  0 siblings, 2 replies; 20+ messages in thread

From: Peter Eisentraut @ 2000-05-10 21:25 UTC (permalink / raw)
  To: The Hermit Hacker <scrappy@hub.org>; +Cc: pgsql-hackers

The Hermit Hacker writes:

> Well, that would explain that, now, wouldn't it?  did we remove this
> somewhere along the way? *raised eyebrow*

There was no setproctitle in 6.5.* either.

I'm guessing that the argv[0] = "the string you want" method no longer
works in FreeBSD 4.0??? In any case, as per previous discussion, I did
write up a more portable and robust setproctitle-like implementation for
our use (which actually uses setproctitle if available), so if this is the
problem it's at least being worked on.

> pgsql% find . -name "*.[ch]" -exec grep setproctitle {} \; -print
> pgsql% pwd
> /pgsql/src/pgsql/src
> pgsql% 

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
@ 2000-05-10 21:35   ` Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 20+ messages in thread

From: Bruce Momjian @ 2000-05-10 21:35 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: The Hermit Hacker <scrappy@hub.org>; pgsql-hackers

[Charset ISO-8859-1 unsupported, filtering to ASCII...]
> The Hermit Hacker writes:
> 
> > Well, that would explain that, now, wouldn't it?  did we remove this
> > somewhere along the way? *raised eyebrow* 
> 
> There was no setproctitle in 6.5.* either.
> 
> I'm guessing that the argv[0] = "the string you want" method no longer
> works in FreeBSD 4.0??? In any case, as per previous discussion, I did

I am quite surprised.  I though all BSD's allows this.  It is done using
kvm.  I am not sure the ps thing works in the backend process is swapped
out.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
@ 2000-05-10 22:16   ` The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 1 reply; 20+ messages in thread

From: The Hermit Hacker @ 2000-05-10 22:16 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-hackers

On Wed, 10 May 2000, Peter Eisentraut wrote:

> The Hermit Hacker writes:
> 
> > Well, that would explain that, now, wouldn't it?  did we remove this
> > somewhere along the way? *raised eyebrow*
> 
> There was no setproctitle in 6.5.* either.
> 
> I'm guessing that the argv[0] = "the string you want" method no longer
> works in FreeBSD 4.0??? In any case, as per previous discussion, I did
> write up a more portable and robust setproctitle-like implementation for
> our use (which actually uses setproctitle if available), so if this is the
> problem it's at least being worked on.

D'oh, okay...I ended up going through the v6.5.* source code too, and
couldn't find it there.  I forget how Bruce had implemented it using
argv[0], and yes, it is definitely broken on FreeBSD 4.0 ...

I'll look at doing the change here locally, since I know
setproctitle() does work, as I find it invaluable to know what is running,
and where ...





^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
@ 2000-05-10 22:30     ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-10 22:30 UTC (permalink / raw)
  To: The Hermit Hacker <scrappy@hub.org>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> D'oh, okay...I ended up going through the v6.5.* source code too, and
> couldn't find it there.  I forget how Bruce had implemented it using
> argv[0], and yes, it is definitely broken on FreeBSD 4.0 ...
> 
> I'll look at doing the change here locally, since I know
> setproctitle() does work, as I find it invaluable to know what is running,
> and where ...

Can you find out if it is broken, or they have stopped supporting it in
FreeBSD.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-10 22:59       ` Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-10 22:59 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > D'oh, okay...I ended up going through the v6.5.* source code too, and
> > couldn't find it there.  I forget how Bruce had implemented it using
> > argv[0], and yes, it is definitely broken on FreeBSD 4.0 ...
> > 
> > I'll look at doing the change here locally, since I know
> > setproctitle() does work, as I find it invaluable to know what is running,
> > and where ...
> 
> Can you find out if it is broken, or they have stopped supporting it in
> FreeBSD.

In 4.0-Rel they're not saying it's gone or going away, just that you 
need to link with -lutil if you use it.  They also state that there's
no standard but that they believe they're using the predominant
convention.

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================






^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
@ 2000-05-10 23:02         ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-10 23:02 UTC (permalink / raw)
  To: Vince Vielhaber <vev@michvhf.com>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> On Wed, 10 May 2000, Bruce Momjian wrote:
> 
> > > D'oh, okay...I ended up going through the v6.5.* source code too, and
> > > couldn't find it there.  I forget how Bruce had implemented it using
> > > argv[0], and yes, it is definitely broken on FreeBSD 4.0 ...
> > > 
> > > I'll look at doing the change here locally, since I know
> > > setproctitle() does work, as I find it invaluable to know what is running,
> > > and where ...
> > 
> > Can you find out if it is broken, or they have stopped supporting it in
> > FreeBSD.
> 
> In 4.0-Rel they're not saying it's gone or going away, just that you 
> need to link with -lutil if you use it.  They also state that there's
> no standard but that they believe they're using the predominant
> convention.

So if you use -lutil, the argv[0] trick works, and if you don't, it
doesn't?  If so, we can get that into the FreeBSD template.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-10 23:06           ` Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-10 23:06 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > On Wed, 10 May 2000, Bruce Momjian wrote:
> > 
> > > > D'oh, okay...I ended up going through the v6.5.* source code too, and
> > > > couldn't find it there.  I forget how Bruce had implemented it using
> > > > argv[0], and yes, it is definitely broken on FreeBSD 4.0 ...
> > > > 
> > > > I'll look at doing the change here locally, since I know
> > > > setproctitle() does work, as I find it invaluable to know what is running,
> > > > and where ...
> > > 
> > > Can you find out if it is broken, or they have stopped supporting it in
> > > FreeBSD.
> > 
> > In 4.0-Rel they're not saying it's gone or going away, just that you 
> > need to link with -lutil if you use it.  They also state that there's
> > no standard but that they believe they're using the predominant
> > convention.
> 
> So if you use -lutil, the argv[0] trick works, and if you don't, it
> doesn't?  If so, we can get that into the FreeBSD template.

'splain the "argv[0] trick" briefly.

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================






^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
@ 2000-05-10 23:07             ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-10 23:07 UTC (permalink / raw)
  To: Vince Vielhaber <vev@michvhf.com>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> > So if you use -lutil, the argv[0] trick works, and if you don't, it
> > doesn't?  If so, we can get that into the FreeBSD template.
> 
> 'splain the "argv[0] trick" briefly.

It is a nifty BSD one.  If you assign argv[0] in the program to a
string, it shows in ps.

	argv[0] = "new ps string";

The Linux method is:

	strcpy(argv[0], "new ps string");

In the second case, you are actually writing into the environment area
use to store args.  Not real great, but it works on Linux.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-10 23:48               ` Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-10 23:48 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > > So if you use -lutil, the argv[0] trick works, and if you don't, it
> > > doesn't?  If so, we can get that into the FreeBSD template.
> > 
> > 'splain the "argv[0] trick" briefly.
> 
> It is a nifty BSD one.  If you assign argv[0] in the program to a
> string, it shows in ps.
> 
> 	argv[0] = "new ps string";
> 
> The Linux method is:
> 
> 	strcpy(argv[0], "new ps string");
> 
> In the second case, you are actually writing into the environment area
> use to store args.  Not real great, but it works on Linux.

This does not:

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


int main(int numargs, char *argv[])
{
int ii;

        argv[0] = "Postgres Power!";

        for(ii=0;ii<100;ii++) sleep(1);

return 0;
}

$ cc test.c -lutil -o test
$ ./test

making it strcpy(argv[0],"Postgres Power!");  didn't either.

But:

making it:  setproctitle("Postgres Power!");  gives this:

34273  p3  S      0:00.00 test: Postgres Power! (test)

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================






^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
@ 2000-05-10 23:56                 ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:07                   ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-10 23:56 UTC (permalink / raw)
  To: Vince Vielhaber <vev@michvhf.com>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> On Wed, 10 May 2000, Bruce Momjian wrote:
> 
> > > > So if you use -lutil, the argv[0] trick works, and if you don't, it
> > > > doesn't?  If so, we can get that into the FreeBSD template.
> > > 
> > > 'splain the "argv[0] trick" briefly.
> > 
> > It is a nifty BSD one.  If you assign argv[0] in the program to a
> > string, it shows in ps.
> > 
> > 	argv[0] = "new ps string";
> > 
> > The Linux method is:
> > 
> > 	strcpy(argv[0], "new ps string");
> > 
> > In the second case, you are actually writing into the environment area
> > use to store args.  Not real great, but it works on Linux.
> 
> This does not:
> 
> #include <stdio.h>
> #include <sys/types.h>
> #include <libutil.h>
> 
> 
> int main(int numargs, char *argv[])
> {
> int ii;
> 
>         argv[0] = "Postgres Power!";
> 
>         for(ii=0;ii<100;ii++) sleep(1);
> 
> return 0;
> }
> 
> $ cc test.c -lutil -o test
> $ ./test
> 
> making it strcpy(argv[0],"Postgres Power!");  didn't either.
> 
> But:
> 
> making it:  setproctitle("Postgres Power!");  gives this:
> 
> 34273  p3  S      0:00.00 test: Postgres Power! (test)

Well, that's interesting.  Our issue with setproctitle is how fast it
is.  Every query changes its proctitle, so it has to be fast.  Tom want
to have setproctitle on backend startup, then use the fast method on
platforms that support it.

Does the existing postgres ps title code work on your Linux?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-11 00:07                   ` Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:12                     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-11 00:07 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > On Wed, 10 May 2000, Bruce Momjian wrote:
> > 
> > > > > So if you use -lutil, the argv[0] trick works, and if you don't, it
> > > > > doesn't?  If so, we can get that into the FreeBSD template.
> > > > 
> > > > 'splain the "argv[0] trick" briefly.
> > > 
> > > It is a nifty BSD one.  If you assign argv[0] in the program to a
> > > string, it shows in ps.
> > > 
> > > 	argv[0] = "new ps string";
> > > 
> > > The Linux method is:
> > > 
> > > 	strcpy(argv[0], "new ps string");
> > > 
> > > In the second case, you are actually writing into the environment area
> > > use to store args.  Not real great, but it works on Linux.
> > 
> > This does not:
> > 
> > #include <stdio.h>
> > #include <sys/types.h>
> > #include <libutil.h>
> > 
> > 
> > int main(int numargs, char *argv[])
> > {
> > int ii;
> > 
> >         argv[0] = "Postgres Power!";
> > 
> >         for(ii=0;ii<100;ii++) sleep(1);
> > 
> > return 0;
> > }
> > 
> > $ cc test.c -lutil -o test
> > $ ./test
> > 
> > making it strcpy(argv[0],"Postgres Power!");  didn't either.
> > 
> > But:
> > 
> > making it:  setproctitle("Postgres Power!");  gives this:
> > 
> > 34273  p3  S      0:00.00 test: Postgres Power! (test)
> 
> Well, that's interesting.  Our issue with setproctitle is how fast it
> is.  Every query changes its proctitle, so it has to be fast.  Tom want
> to have setproctitle on backend startup, then use the fast method on
> platforms that support it.
> 
> Does the existing postgres ps title code work on your Linux?

I'm assuming you're not asking me..

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================






^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:07                   ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
@ 2000-05-11 00:12                     ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:16                       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-11 00:12 UTC (permalink / raw)
  To: Vince Vielhaber <vev@michvhf.com>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> > > making it:  setproctitle("Postgres Power!");  gives this:
> > > 
> > > 34273  p3  S      0:00.00 test: Postgres Power! (test)
> > 
> > Well, that's interesting.  Our issue with setproctitle is how fast it
> > is.  Every query changes its proctitle, so it has to be fast.  Tom want
> > to have setproctitle on backend startup, then use the fast method on
> > platforms that support it.
> > 
> > Does the existing postgres ps title code work on your Linux?
> 
> I'm assuming you're not asking me..

I thought I was.  :-)

I now realize you are running FreeBSD.  Yikes.

So neither works.  Well, that is a problem.  Does the -lutil help?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:07                   ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:12                     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-11 00:16                       ` Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:21                         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 1 reply; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-11 00:16 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > > > making it:  setproctitle("Postgres Power!");  gives this:
> > > > 
> > > > 34273  p3  S      0:00.00 test: Postgres Power! (test)
> > > 
> > > Well, that's interesting.  Our issue with setproctitle is how fast it
> > > is.  Every query changes its proctitle, so it has to be fast.  Tom want
> > > to have setproctitle on backend startup, then use the fast method on
> > > platforms that support it.
> > > 
> > > Does the existing postgres ps title code work on your Linux?
> > 
> > I'm assuming you're not asking me..
> 
> I thought I was.  :-)
> 
> I now realize you are running FreeBSD.  Yikes.
> 
> So neither works.  Well, that is a problem.  Does the -lutil help?
> 
> 

No, I compiled every time with -lutil

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================






^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:07                   ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:12                     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:16                       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
@ 2000-05-11 00:21                         ` Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:41                           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  0 siblings, 1 reply; 20+ messages in thread

From: Bruce Momjian @ 2000-05-11 00:21 UTC (permalink / raw)
  To: Vince Vielhaber <vev@michvhf.com>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

> > I thought I was.  :-)
> > 
> > I now realize you are running FreeBSD.  Yikes.
> > 
> > So neither works.  Well, that is a problem.  Does the -lutil help?
> > 
> > 
> 
> No, I compiled every time with -lutil

Oh.  Can you look at the setproctitle code on your platform and see how
it implements it?

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 21:25 ` Re: setproctitle() no longer used? Peter Eisentraut <peter_e@gmx.net>
  2000-05-10 22:16   ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
  2000-05-10 22:30     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 22:59       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:02         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:06           ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:07             ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-10 23:48               ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-10 23:56                 ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:07                   ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:12                     ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  2000-05-11 00:16                       ` Re: setproctitle() no longer used? Vince Vielhaber <vev@michvhf.com>
  2000-05-11 00:21                         ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
@ 2000-05-11 00:41                           ` Vince Vielhaber <vev@michvhf.com>
  0 siblings, 0 replies; 20+ messages in thread

From: Vince Vielhaber @ 2000-05-11 00:41 UTC (permalink / raw)
  To: Bruce Momjian <pgman@candle.pha.pa.us>; +Cc: The Hermit Hacker <scrappy@hub.org>; Peter Eisentraut <peter_e@gmx.net>; pgsql-hackers

On Wed, 10 May 2000, Bruce Momjian wrote:

> > > I thought I was.  :-)
> > > 
> > > I now realize you are running FreeBSD.  Yikes.
> > > 
> > > So neither works.  Well, that is a problem.  Does the -lutil help?
> > > 
> > > 
> > 
> > No, I compiled every time with -lutil
> 
> Oh.  Can you look at the setproctitle code on your platform and see how
> it implements it?

I've attached it since it's small.

Vince.
-- 
==========================================================================
Vince Vielhaber -- KA8CSH    email: vev@michvhf.com    http://www.pop4.net
 128K ISDN from $22.00/mo - 56K Dialup from $16.00/mo at Pop4 Networking
        Online Campground Directory    http://www.camping-usa.com
       Online Giftshop Superstore    http://www.cloudninegifts.com
==========================================================================

Attachments:

setproctitle.c (text/plain, 4.3K) download /* * Copyright (c) 1995 Peter Wemm <peter@freebsd.org> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, is permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice immediately at the beginning of the file, without modification, * this list of conditions, and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Absolutely no warranty of function or purpose is made by the author * Peter Wemm. * * $FreeBSD: src/lib/libutil/setproctitle.c,v 1.11 1999/11/17 21:12:17 brian Exp $ */ #include <sys/types.h> #include <sys/param.h> #include <sys/exec.h> #include <sys/sysctl.h> #include <vm/vm.h> #include <vm/vm_param.h> #include <vm/pmap.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> /* * Older FreeBSD 2.0, 2.1 and 2.2 had different ps_strings structures and * in different locations. * 1: old_ps_strings at the very top of the stack. * 2: old_ps_strings at SPARE_USRSPACE below the top of the stack. * 3: ps_strings at the very top of the stack. * This attempts to support a kernel built in the #2 and #3 era. */ struct old_ps_strings { char *old_ps_argvstr; int old_ps_nargvstr; char *old_ps_envstr; int old_ps_nenvstr; }; #define OLD_PS_STRINGS ((struct old_ps_strings *) \ (USRSTACK - SPARE_USRSPACE - sizeof(struct old_ps_strings))) #if defined(__STDC__) /* from other parts of sendmail */ #include <stdarg.h> #else #include <varargs.h> #endif #define SPT_BUFSIZE 2048 /* from other parts of sendmail */ extern char * __progname; /* is this defined in a .h anywhere? */ void #if defined(__STDC__) setproctitle(const char *fmt, ...) #else setproctitle(fmt, va_alist) const char *fmt; va_dcl #endif { static struct ps_strings *ps_strings; static char buf[SPT_BUFSIZE]; static char obuf[SPT_BUFSIZE]; static char **oargv, *kbuf; static int oargc = -1; static char *nargv[2] = { buf, NULL }; char **nargvp; int nargc; va_list ap; size_t len; unsigned long ul_ps_strings; int oid[4]; #if defined(__STDC__) va_start(ap, fmt); #else va_start(ap); #endif if (fmt) { buf[sizeof(buf) - 1] = '\0'; /* print program name heading for grep */ (void) snprintf(buf, sizeof(buf), "%s: ", __progname); /* * can't use return from sprintf, as that is the count of how * much it wanted to write, not how much it actually did. */ len = strlen(buf); /* print the argument string */ (void) vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); nargvp = nargv; nargc = 1; kbuf = buf; } else if (*obuf != '\0') { /* Idea from NetBSD - reset the title on fmt == NULL */ nargvp = oargv; nargc = oargc; kbuf = obuf; } else /* Nothing to restore */ return; va_end(ap); /* Set the title into the kernel cached command line */ oid[0] = CTL_KERN; oid[1] = KERN_PROC; oid[2] = KERN_PROC_ARGS; oid[3] = getpid(); sysctl(oid, 4, 0, 0, kbuf, strlen(kbuf) + 1); if (ps_strings == NULL) { len = sizeof(ul_ps_strings); if (sysctlbyname("kern.ps_strings", &ul_ps_strings, &len, NULL, 0) == -1) ul_ps_strings = PS_STRINGS; ps_strings = (struct ps_strings *)ul_ps_strings; } /* PS_STRINGS points to zeroed memory on a style #2 kernel */ if (ps_strings->ps_argvstr) { /* style #3 */ if (oargc == -1) { /* Record our original args */ oargc = ps_strings->ps_nargvstr; oargv = ps_strings->ps_argvstr; for (nargc = len = 0; nargc < oargc; nargc++) { snprintf(obuf + len, sizeof(obuf) - len, "%s%s", len ? " " : "", oargv[nargc]); if (len) len++; len += strlen(oargv[nargc]); if (len >= sizeof(obuf)) break; } } ps_strings->ps_nargvstr = nargc; ps_strings->ps_argvstr = nargvp; } else { /* style #2 - we can only restore our first arg :-( */ if (*obuf == '\0') strncpy(obuf, OLD_PS_STRINGS->old_ps_argvstr, sizeof(obuf) - 1); OLD_PS_STRINGS->old_ps_nargvstr = 1; OLD_PS_STRINGS->old_ps_argvstr = nargvp[0]; } }
^ permalink raw reply [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
@ 2000-05-11 11:48 ` The Hermit Hacker <scrappy@hub.org>
  2000-05-11 15:32   ` Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 1 reply; 20+ messages in thread

From: The Hermit Hacker @ 2000-05-11 11:48 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Bruce Momjian <pgman@candle.pha.pa.us>; Vince Vielhaber <vev@michvhf.com>; pgsql-hackers

On Thu, 11 May 2000, Peter Eisentraut wrote:

> On Wed, 10 May 2000, Bruce Momjian wrote:
> 
> > Oh.  Can you look at the setproctitle code on your platform and see
> > how it implements it?
> 
> In the end I believe we'll make the world a better place if we're using
> setproctitle when available. Sendmail does. If someone really complains
> about speed loss we can always make it an option not to use it, but I
> won't buy into that until I see some profiling evidence.

Its a rare thing, but definitely agree with Peter here :)





^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
  2000-05-11 11:48 ` Re: setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
@ 2000-05-11 15:32   ` Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 20+ messages in thread

From: Bruce Momjian @ 2000-05-11 15:32 UTC (permalink / raw)
  To: The Hermit Hacker <scrappy@hub.org>; +Cc: Peter Eisentraut <peter_e@gmx.net>; Vince Vielhaber <vev@michvhf.com>; pgsql-hackers

> On Thu, 11 May 2000, Peter Eisentraut wrote:
> 
> > On Wed, 10 May 2000, Bruce Momjian wrote:
> > 
> > > Oh.  Can you look at the setproctitle code on your platform and see
> > > how it implements it?
> > 
> > In the end I believe we'll make the world a better place if we're using
> > setproctitle when available. Sendmail does. If someone really complains
> > about speed loss we can always make it an option not to use it, but I
> > won't buy into that until I see some profiling evidence.
> 
> Its a rare thing, but definitely agree with Peter here :)

I think I do too.  Let me add this to the TODO list:

	* use setproctitle() if it exists for 'ps' display of status

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
@ 2000-05-11 15:28 ` Bruce Momjian <pgman@candle.pha.pa.us>
  1 sibling, 0 replies; 20+ messages in thread

From: Bruce Momjian @ 2000-05-11 15:28 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Vince Vielhaber <vev@michvhf.com>; The Hermit Hacker <scrappy@hub.org>; pgsql-hackers

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> On Wed, 10 May 2000, Bruce Momjian wrote:
> 
> > Oh.  Can you look at the setproctitle code on your platform and see
> > how it implements it?
> 
> In the end I believe we'll make the world a better place if we're using
> setproctitle when available. Sendmail does. If someone really complains
> about speed loss we can always make it an option not to use it, but I
> won't buy into that until I see some profiling evidence.

Good point.  I just did it because it worked on BSD, and I don't have
setproctitle.  If sendmail does it by default if setproctitle exists,
maybe that is the way to go.

BSDI 4.01 doesn't have setproctitle, but I don't need it because I can
just assign anything in there.

I saw the FreeBSD code, and it seems they have added a sysctl() call in
the library setproctitle code to handle it.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread

* Re: setproctitle() no longer used?
@ 2000-05-11 15:25 Bruce Momjian <pgman@candle.pha.pa.us>
  0 siblings, 0 replies; 20+ messages in thread

From: Bruce Momjian @ 2000-05-11 15:25 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: Vince Vielhaber <vev@michvhf.com>; The Hermit Hacker <scrappy@hub.org>; pgsql-hackers

[Charset iso-8859-1 unsupported, filtering to ASCII...]
> On Wed, 10 May 2000, Bruce Momjian wrote:
> 
> > It is a nifty BSD one.  If you assign argv[0] in the program to a
> > string, it shows in ps.
> > 
> > 	argv[0] = "new ps string";
> > 
> > The Linux method is:
> 
> Maybe I should add that this could more accurately be called the `SysV
> method' and also works on SysV-derived models. Heubrid (a.k.a. hogwash)
> systems such as Solaris and HPUX may support both or none, depending on
> the time of day.

OK.

> 
> > 
> > 	strcpy(argv[0], "new ps string");
> > 
> > In the second case, you are actually writing into the environment area
> > use to store args.  Not real great, but it works on Linux.
> 
> You just copy the environment somewhere else before you do that. Or don't
> use the environment. Not a big deal.

But do they really do that?  The scary part about the Linux code in
pg_status.h is that is just zeros out all the argv bytes and starts
writing, and that is environment memory.

Now, I do some tricks in postmaster.c so I know I have at least 5
elements to argv[], but I never do anything that makes sure I have
enough environment space to start copying strings in there.

	argv[0] = "string"
	strcpy(argv[0], "string");

The first makes argv[0] point into user-space memory, while the second
writes into environment memory.  (Allowing ps to dynamically read
argv[0] memory that is pointing to user-space is a kvm() trick.)

Linux people seem to be happy with their version, but frankly, I would
not allow it on BSD.  I would _at_ _least_ put something in postmaster.c
so I _knew_ that argv[0] had a reasonable size for me to copy into it.
(Massimo write the Linux code, I believe.)

Guess it is more a philosophical issue.  Linux folks like it because it
works, while I don't because it is not bullet-proof.

-- 
  Bruce Momjian                        |  http://www.op.net/~candle
  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



^ permalink  raw  reply  [nested|flat] 20+ messages in thread


end of thread, other threads:[~2000-05-11 15:32 UTC | newest]

Thread overview: 20+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2000-05-10 11:57 setproctitle() no longer used? The Hermit Hacker <scrappy@hub.org>
2000-05-10 21:25 ` Peter Eisentraut <peter_e@gmx.net>
2000-05-10 21:35   ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-10 22:16   ` The Hermit Hacker <scrappy@hub.org>
2000-05-10 22:30     ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-10 22:59       ` Vince Vielhaber <vev@michvhf.com>
2000-05-10 23:02         ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-10 23:06           ` Vince Vielhaber <vev@michvhf.com>
2000-05-10 23:07             ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-10 23:48               ` Vince Vielhaber <vev@michvhf.com>
2000-05-10 23:56                 ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-11 00:07                   ` Vince Vielhaber <vev@michvhf.com>
2000-05-11 00:12                     ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-11 00:16                       ` Vince Vielhaber <vev@michvhf.com>
2000-05-11 00:21                         ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-11 00:41                           ` Vince Vielhaber <vev@michvhf.com>
2000-05-11 11:48 ` The Hermit Hacker <scrappy@hub.org>
2000-05-11 15:32   ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-11 15:28 ` Bruce Momjian <pgman@candle.pha.pa.us>
2000-05-11 15:25 Re: setproctitle() no longer used? Bruce Momjian <pgman@candle.pha.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox