Received: from candle.pha.pa.us (pgman@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id LAA90590 for ; Thu, 11 May 2000 11:27:02 -0400 (EDT) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id LAA13642; Thu, 11 May 2000 11:25:47 -0400 (EDT) From: Bruce Momjian Message-Id: <200005111525.LAA13642@candle.pha.pa.us> Subject: Re: setproctitle() no longer used? In-Reply-To: from Peter Eisentraut at "May 11, 2000 11:42:08 am" To: Peter Eisentraut Date: Thu, 11 May 2000 11:25:47 -0400 (EDT) CC: Vince Vielhaber , The Hermit Hacker , pgsql-hackers@postgresql.org X-Mailer: ELM [version 2.4ME+ PL72 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archive-Number: 200005/695 [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