Thread

  1. Re: [HACKERS] Open 6.4 items

    Billy G. Allie <bill.allie@mug.org> — 1998-10-29T06:48:26Z

    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.
    -- 
    ____       | Billy G. Allie    | Domain....: Bill.Allie@mug.org
    |  /|      | 7436 Hartwell     | Compuserve: 76337,2061
    |-/-|----- | Dearborn, MI 48126| MSN.......: B_G_Allie@email.msn.com
    |/  |LLIE  | (313) 582-1540    | 
    
    
    
    
  2. Re: [HACKERS] Open 6.4 items

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-10-29T07:07:59Z

    > 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.
    
    Wow, that really is strange.  Seems like with the -f, it looks in one
    place, as though it knows the child did not exec, so they params must be
    the same, while with no -f, it looks in the proper area.  The really
    weird thing is that even the postmaster is called postgres.  That is
    bizarre.
    
    
    -- 
      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, Pennsylvania 19026
    
    
  3. Re: [HACKERS] Open 6.4 items

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-10-29T07:31:20Z

    > 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, Pennsylvania 19026
    
    
  4. RE: [HACKERS] Open 6.4 items

    Taral <taral@mail.utexas.edu> — 1998-10-29T17:05:38Z

    > Wow, that really is strange.  Seems like with the -f, it looks in one
    > place, as though it knows the child did not exec, so they params must be
    > the same, while with no -f, it looks in the proper area.  The really
    > weird thing is that even the postmaster is called postgres.  That is
    > bizarre.
    
    Yes. With -f, it looks in the process's argv... without, it looks in the
    task struct where only the executable name was stored (no path or anything
    else). It's a feature to prevent processes that spoof as something else...
    (not very effective, IMHO)
    
    Taral
    
    
    
  5. Re: [HACKERS] Open 6.4 items

    Bruce Momjian <maillist@candle.pha.pa.us> — 1998-10-29T17:34:59Z

    > 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
    
    My guess is that ps without -f looks at the inode that opened the file,
    and postmaster and postgres have the same inode because postmaster is
    symlinked to postgres.
    
    -- 
      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, Pennsylvania 19026