From: Bruce Momjian <pgman@candle.pha.pa.us>
To: Peter Eisentraut <peter_e@gmx.net>
Cc: Vince Vielhaber <vev@michvhf.com>
Cc: The Hermit Hacker <scrappy@hub.org>
Cc: pgsql-hackers@postgresql.org
Subject: Re: setproctitle() no longer used?
Date: Thu, 11 May 2000 11:25:47 -0400 (EDT)
Message-ID: <200005111525.LAA13642@candle.pha.pa.us> (raw)
In-Reply-To: <Pine.GSO.4.02A.10005111137220.6113-100000@Gepard.DoCS.UU.SE>
[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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: pgman@candle.pha.pa.us, peter_e@gmx.net, vev@michvhf.com, scrappy@hub.org
Subject: Re: setproctitle() no longer used?
In-Reply-To: <200005111525.LAA13642@candle.pha.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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