Re: setproctitle() no longer used?
От | Bruce Momjian |
---|---|
Тема | Re: setproctitle() no longer used? |
Дата | |
Msg-id | 200005111525.LAA13642@candle.pha.pa.us обсуждение исходный текст |
Ответ на | setproctitle() no longer used? (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, Pennsylvania19026
В списке pgsql-hackers по дате отправления: