Thread: setproctitle() no longer used?
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
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
[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, Pennsylvania19026
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 ...
> 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
> 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
> > 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
> 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
> > > 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
> > 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, Pennsylvania19026
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.net128K ISDN from $22.00/mo - 56K Dialup from $16.00/moat Pop4 Networking Online Campground Directory http://www.camping-usa.com Online Giftshop Superstore http://www.cloudninegifts.com ==========================================================================
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 :)
[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
[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, Pennsylvania19026
> 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, Pennsylvania19026