Re: [HACKERS] Open 6.4 items

Поиск
Список
Период
Сортировка
От Bruce Momjian
Тема Re: [HACKERS] Open 6.4 items
Дата
Msg-id 199810290731.CAA12278@candle.pha.pa.us
обсуждение исходный текст
Ответ на Re: [HACKERS] Open 6.4 items  ("Billy G. Allie" <Bill.Allie@mug.org>)
Список pgsql-hackers
> Bruce Momjian wrote:
> > > Doesn't work under Solaris, but, then again, neither does sendamil's, so
> > > that isn't a shock :)
> > 
> > Man, if sendmail's doesn't work, that is really broken.
> 
> If you want strange, here is the output from the UnixWare 7 ps command with 
> some different options:
> 
> $ ps -ef | fgrep post
>    pgsql 10775     1   TS  80  0 01:34:12 ?  0:00 postmaster -S -i -o -F 
>    pgsql 10869 10775   TS  80  0 01:45:30 ?  0:00 postmaster -S -i -o -F 
> 
> $ ps -e | fgrep post
>  10775   TS  80 ?        0:00 postgres
>  10869   TS  80 ?        0:00 postgres
> 
> Notice that the PIDs are the same even if the program name is different 
> depending on the use of the 'f' option.

That is really bizarre.  The postmaster name is changed to postgres too!


Ah, I now know why things work on Linux.  Massimo did more than just
parameterize my argv code.  In include/utils/ps_status.h, he put in
Linux-specific code to handle the ps args.  Seems under Linux, only
argv[0] can be modified for ps display, for some reason.  He erases the
other args, and puts everything in argv[0].

Under non-linux, he uses the argv[0-4] for various displays, like my
orignal code.  The major issue is that for Linux, he writes directly
into argv[0] memory.  He sets the normal i/o static parameters in the
start of the string, then marks the next position, and writes status
information into there.

In non-Linux, we don't write into argv[0], but change argv[0..4] to
point to our own alloc'ed strings, where the memory sits in our own
address space, not in the proc 'environment' address space.  Getting
'ps' to display process address space strings is a real trick, so it is
not surprising some O/S's don't support it.

He may have done it all in argv[0] because he is expanding the size of
argv[0], and if they are layed out sequentially in environment memory,
the changes would over-write each other.  What I don't understand is why
ps when it goes to look at argv[1], does not see garbage because it may
be pointing into the middle of the argv[0] string.)  Can a Linux user
use ps to display all the params, like 'ps -ef' and see if it is showing
argv[1] as part of the argv[0] string?  You may have to get a wide
display to see it all.

The great news is that it seems it is working to write directly into the
environment address space under Linux, so we don't need set_proctitle,
and it is very fast.

Non-linux platforms are not writing directly to environment memory, but
are using the argv[0..4] trick.

FYI, I have re-exec'ed the postmaster in postmaster.h so it has 4 args.
argc is passed as a value to the program, so you can't change it, and if
you don't do the re-exec, ps only looks at the argv[0], and under
non-linux, that is bad because we use argv[0...4].


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@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 по дате отправления:

Предыдущее
От: dg@informix.com (David Gould)
Дата:
Сообщение: Re: [HACKERS] Another bug in pg_operator.h
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Open 6.4 items