Re: setproctitle() no longer used?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Vince Vielhaber <vev(at)michvhf(dot)com>, The Hermit Hacker <scrappy(at)hub(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: setproctitle() no longer used?
Date: 2000-05-11 15:25:47
Message-ID: 200005111525.LAA13642@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-05-11 15:28:12 Re: setproctitle() no longer used?
Previous Message Ross J. Reedstrom 2000-05-11 15:23:42 Re: Now 376175 lines of code