Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] Open 6.4 items

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: Bill(dot)Allie(at)mug(dot)org
Cc: scrappy(at)hub(dot)org, brook(at)trillium(dot)NMSU(dot)Edu, jwieck(at)debis(dot)com, hackers(at)postgreSQL(dot)org, dz(at)cs(dot)unitn(dot)it
Subject: Re: [HACKERS] Open 6.4 items
Date: 1998-10-29 07:31:20
Message-ID: 199810290731.CAA12278@candle.pha.pa.us (view raw or flat)
Thread:
Lists: 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(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

In response to

pgsql-hackers by date

Next:From: Andreas ZeugswetterDate: 1998-10-29 08:35:20
Subject: AW: [HACKERS] Last call? (Siemens RM Port)
Previous:From: David GouldDate: 1998-10-29 07:15:41
Subject: Re: [HACKERS] Another bug in pg_operator.h

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group