Thread: setproctitle()

setproctitle()

From
Bruce Momjian
Date:
Seems BSD/OS 4.01 has setproctitle() in libutil.o, even though there is
no include file nor manual page.

I checked the library source, and it is a very light-weight function. 
It grabs an argv global from crt0.o, and changes the ps args.  Very fast.

I now see that systems that use setproctitle() seem totally broken for
updates.  The code says:
       setproctitle("%s %s %s %s %s", execname, hostname, username, db...

#define PS_SET_STATUS(status) \       do { strcpy(Ps_status_buffer, (status)); } while (0)

Of course, there is no linkage between Ps_status_buffer and the
setproctitle args here, so it is no-op.  The fix is to move
setproctitle() down into PS_SET_STATUS().

Seems this is Marc's new code:
date: 2000/05/12 13:58:24;  author: scrappy;  state: Exp;  lines: +2 -1Add two checks ... one for setproctitle and one
for-lutil ...Don't do anything with them at this time, but am working on that ...
 

I know we have been talking about using setproctitle() in all cases that
support it, and in fact we now do that.  What we don't do is use
setproctitle() to update the status for each query.

So it seems that he has enabled it on my platform.  Do people want
setproctitle() to update for every query for 7.01?  I have seen FreeBSD
and BSDI implementations, and they are both light-weight.

Comments?

--  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
 


Re: setproctitle()

From
The Hermit Hacker
Date:
On Tue, 23 May 2000, Bruce Momjian wrote:

> Seems BSD/OS 4.01 has setproctitle() in libutil.o, even though there is
> no include file nor manual page.
> 
> I checked the library source, and it is a very light-weight function. 
> It grabs an argv global from crt0.o, and changes the ps args.  Very fast.
> 
> I now see that systems that use setproctitle() seem totally broken for
> updates.  The code says:
> 
>         setproctitle("%s %s %s %s %s", execname, hostname, username, db...
> 
> #define PS_SET_STATUS(status) \
>         do { strcpy(Ps_status_buffer, (status)); } while (0)
> 
> Of course, there is no linkage between Ps_status_buffer and the
> setproctitle args here, so it is no-op.  The fix is to move
> setproctitle() down into PS_SET_STATUS().
> 
> Seems this is Marc's new code:
> 
>     date: 2000/05/12 13:58:24;  author: scrappy;  state: Exp;  lines: +2 -1
>     
>     Add two checks ... one for setproctitle and one for -lutil ...
>     
>     Don't do anything with them at this time, but am working on that ...
> 
> I know we have been talking about using setproctitle() in all cases that
> support it, and in fact we now do that.  What we don't do is use
> setproctitle() to update the status for each query.
> 
> So it seems that he has enabled it on my platform.  Do people want
> setproctitle() to update for every query for 7.01?  I have seen FreeBSD
> and BSDI implementations, and they are both light-weight.
> 
> Comments?

I would like to see it, but not for v7.0.1 ... unless you can figure out a
cleaner way of doing it, the coding changes would be extensive ...

I looked at it, and unless we go with global variables *yeech*, you would
have to pass down the "fixed" part of the setproctitle to sub-functions
(ie. argv[0-4](?)) ... I asked on one of the freebsd lists if anyone could
suggest a way of getting 'argv[0]', but never did hear anything back ...

If you want, you could just added, for v7.0.1, a simple addition of 'if
__FreeBSD__' to the code, so that setproctitle is only used under FreeBSD
...




Re: setproctitle()

From
Alfred Perlstein
Date:
* The Hermit Hacker <scrappy@hub.org> [000523 16:50] wrote:
> 
> I would like to see it, but not for v7.0.1 ... unless you can figure out a
> cleaner way of doing it, the coding changes would be extensive ...
> 
> I looked at it, and unless we go with global variables *yeech*, you would
> have to pass down the "fixed" part of the setproctitle to sub-functions
> (ie. argv[0-4](?)) ... I asked on one of the freebsd lists if anyone could
> suggest a way of getting 'argv[0]', but never did hear anything back ...

Can you clarify the question please?

Provide pseudo-code and I should be able to whip something up.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."


Re: setproctitle()

From
Bruce Momjian
Date:
> > Comments?
> 
> I would like to see it, but not for v7.0.1 ... unless you can figure out a
> cleaner way of doing it, the coding changes would be extensive ...
> 
> I looked at it, and unless we go with global variables *yeech*, you would
> have to pass down the "fixed" part of the setproctitle to sub-functions
> (ie. argv[0-4](?)) ... I asked on one of the freebsd lists if anyone could
> suggest a way of getting 'argv[0]', but never did hear anything back ...
> 
> If you want, you could just added, for v7.0.1, a simple addition of 'if
> __FreeBSD__' to the code, so that setproctitle is only used under FreeBSD
> ...

No, it is pretty easy to do it in pg_status.h alone.  The trick is to
do sprintf(ps_status_buffer, "val val %s"), then use that in
setproctitle for every command.

I will code it up if no one objects.

--  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
 


Re: setproctitle()

From
Bruce Momjian
Date:
I am on it.  I will post the code here.

> * The Hermit Hacker <scrappy@hub.org> [000523 16:50] wrote:
> > 
> > I would like to see it, but not for v7.0.1 ... unless you can figure out a
> > cleaner way of doing it, the coding changes would be extensive ...
> > 
> > I looked at it, and unless we go with global variables *yeech*, you would
> > have to pass down the "fixed" part of the setproctitle to sub-functions
> > (ie. argv[0-4](?)) ... I asked on one of the freebsd lists if anyone could
> > suggest a way of getting 'argv[0]', but never did hear anything back ...
> 
> Can you clarify the question please?
> 
> Provide pseudo-code and I should be able to whip something up.
> 
> --
> -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
> "I have the heart of a child; I keep it in a jar on my desk."
> 


--  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
 


Re: setproctitle()

From
Tom Lane
Date:
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> No, it is pretty easy to do it in pg_status.h alone.  The trick is to
> do sprintf(ps_status_buffer, "val val %s"), then use that in
> setproctitle for every command.

> I will code it up if no one objects.

Well, at this point committed changes are going to go out in 7.0.1
with essentially zero beta testing.  Are you sure you've not introduced
any portability issues?

As long as the changes are only enabled for platform(s) you've been able
to test, I've got no objection.  Otherwise I'm a bit worried...
        regards, tom lane


Re: setproctitle()

From
Bruce Momjian
Date:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > No, it is pretty easy to do it in pg_status.h alone.  The trick is to
> > do sprintf(ps_status_buffer, "val val %s"), then use that in
> > setproctitle for every command.
> 
> > I will code it up if no one objects.
> 
> Well, at this point committed changes are going to go out in 7.0.1
> with essentially zero beta testing.  Are you sure you've not introduced
> any portability issues?
> 
> As long as the changes are only enabled for platform(s) you've been able
> to test, I've got no objection.  Otherwise I'm a bit worried...

I am too, but Marc put the setproctitle() stuff in there.  I just made
it work.  Whether it should be in there is a separate issue I will let
Marc address.

If we turn it off in configure.in, then it will stay dormant until
activated again.

--  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
 


Re: setproctitle()

From
The Hermit Hacker
Date:
On Wed, 24 May 2000, Bruce Momjian wrote:

> > Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > > No, it is pretty easy to do it in pg_status.h alone.  The trick is to
> > > do sprintf(ps_status_buffer, "val val %s"), then use that in
> > > setproctitle for every command.
> > 
> > > I will code it up if no one objects.
> > 
> > Well, at this point committed changes are going to go out in 7.0.1
> > with essentially zero beta testing.  Are you sure you've not introduced
> > any portability issues?
> > 
> > As long as the changes are only enabled for platform(s) you've been able
> > to test, I've got no objection.  Otherwise I'm a bit worried...
> 
> I am too, but Marc put the setproctitle() stuff in there.  I just made
> it work.  Whether it should be in there is a separate issue I will let
> Marc address.
> 
> If we turn it off in configure.in, then it will stay dormant until
> activated again.

I have no probs with making it "dormant" for v7.0.1 and then activiating
it for testing afterwards ...




Re: setproctitle()

From
Bruce Momjian
Date:
> > I am too, but Marc put the setproctitle() stuff in there.  I just made
> > it work.  Whether it should be in there is a separate issue I will let
> > Marc address.
> > 
> > If we turn it off in configure.in, then it will stay dormant until
> > activated again.
> 
> I have no probs with making it "dormant" for v7.0.1 and then activiating
> it for testing afterwards ...

Is that what you want to do?  It will need to be done in configure.in. 
I don't know how to do it in there.


--  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
 


Re: setproctitle()

From
The Hermit Hacker
Date:
done ... :)


On Wed, 24 May 2000, Bruce Momjian wrote:

> > > I am too, but Marc put the setproctitle() stuff in there.  I just made
> > > it work.  Whether it should be in there is a separate issue I will let
> > > Marc address.
> > > 
> > > If we turn it off in configure.in, then it will stay dormant until
> > > activated again.
> > 
> > I have no probs with making it "dormant" for v7.0.1 and then activiating
> > it for testing afterwards ...
> 
> Is that what you want to do?  It will need to be done in configure.in. 
> I don't know how to do it in there.
> 
> 
> -- 
>   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
> 

Marc G. Fournier                   ICQ#7615664               IRC Nick: Scrappy
Systems Administrator @ hub.org 
primary: scrappy@hub.org           secondary: scrappy@{freebsd|postgresql}.org 



Re: setproctitle()

From
Bruce Momjian
Date:
> 
> done ... :)
> 

Great.  I am adding it to my configure run.  Let's re-enable in 7.1.

--  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
 


Re: setproctitle()

From
Peter Eisentraut
Date:
If y'all just want to be a little patient, I have this all coded up as per
various previous discussions and I'm just waiting for the branch. :)

Bruce Momjian writes:

> I know we have been talking about using setproctitle() in all cases that
> support it, and in fact we now do that.  What we don't do is use
> setproctitle() to update the status for each query.
> 
> So it seems that he has enabled it on my platform.  Do people want
> setproctitle() to update for every query for 7.01?  I have seen FreeBSD
> and BSDI implementations, and they are both light-weight.
> 
> Comments?
> 
> 

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden