[comp.sources.wanted] Wanted Dead or Alive: A ps that displays all command args...

lenny@icus.UUCP (Lenny Tropiano) (06/21/88)

In article <2300002@cpe> tif@cpe.UUCP writes:
|>
|>Written  6:57 pm  Jun 13, 1988 by tarkus.UUCP!jcs in cpe:comp.sources.w
|>>Has anybody got a ps program that will display the arguments that were passed
|>>to the currently running programs?  The version that came with the machine
|>>has got to go, I can't stand it anymore..  Thanks in advance.
|>
|>I thought the "-f" option to ps was standard.
|>
|>For lenny who said it can't be done:  It can be done, it's just not
|>that straight-forward.
|>
|>			Paul Chamberlain
|>			Computer Product Engineering, Tandy Corp.
|>			ihnp4!sys1!cpe!tif

Ok.  I was wrong ... It can be done.  For some reason AT&T took a short-cut
and only displayed the u_comm string in the user block that only contains
the first argument.  The real way of doing it and really the "-f"
option of the ps(1) should do this.  But as usual...

A few people mentioned the way of doing it is to look up the user's stack
space in memory and read back the arguments from the "argv-block".  Likewise
you could also print the environment (like Bezerkley BSD UNIX does)...  If
anyone cares to do this before I hack it myself, by all means.  

Of course the argv can be changed easily by a program giving you erroneous
results, the user.u_comm cannot be changed [as easily :-), I learned never
to say never]...

-Lenny
-- 
US MAIL  : Lenny Tropiano, ICUS Software Systems      IIIII  CCC U   U  SSS
           PO Box 1                                     I   C    U   U S
           Islip Terrace, New York  11752               I   C    U   U  SS 
PHONE    : (516) 968-8576 [H] (516) 582-5525 [W]        I   C    U   U    S
TELEX    : 154232428 [ICUS]                           IIIII  CCC  UUU  SSS 
AT&T MAIL: ...attmail!icus!lenny  
UUCP     : ...{talcott, boulder, pacbell, sbcs, mtune, bc-cis}!icus!lenny 

pjh@mccc.UUCP (Pete Holsberg) (06/21/88)

In article <398@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
...In article <2300002@cpe> tif@cpe.UUCP writes:
...|>
...|>Written  6:57 pm  Jun 13, 1988 by tarkus.UUCP!jcs in cpe:comp.sources.w
...|>>Has anybody got a ps program that will display the arguments that were passed
...|>>to the currently running programs?  The version that came with the machine
...|>>has got to go, I can't stand it anymore..  Thanks in advance.
...|>
...|>I thought the "-f" option to ps was standard.
...|>
...|>For lenny who said it can't be done:  It can be done, it's just not
...|>that straight-forward.
...|>
...|>			Paul Chamberlain
...|>			Computer Product Engineering, Tandy Corp.
...|>			ihnp4!sys1!cpe!tif
...
...Ok.  I was wrong ... It can be done.  For some reason AT&T took a short-cut
...and only displayed the u_comm string in the user block that only contains
...the first argument.  The real way of doing it and really the "-f"
...option of the ps(1) should do this.  But as usual...
...
I lost you, Lenny.  The ps -f on the 3b1 doesn't give anywhere near as
much info as the same command on the 3b2.  So what do we use on the 3b1
to get all that nice stuff?

ford@elgar.UUCP (Mike "Ford" Ditto) (06/23/88)

In article <398@icus.UUCP> lenny@icus.UUCP (Lenny Tropiano) writes:
>Ok.  I was wrong ... It can be done.  For some reason AT&T took a short-cut
>and only displayed the u_comm string in the user block that only contains
>the first argument.  The real way of doing it and really the "-f"
>option of the ps(1) should do this.  But as usual...

THe shortcut on the Unix PC is in the exec function, which doesn't
store the full args.  On a normal system V (at least in release 2)
there is a field in the user area (called u_psargs) reserved for
storing the first 40-or-so characters of the exec arguments.  This is
what ps normally prints, but for some reason, the Unix PC doesn't have
this field, so ps prints u.u_comm (which is NOT argv[0], but the
"path" argument to exec - the name of the file being run).

>A few people mentioned the way of doing it is to look up the user's stack
>space in memory and read back the arguments from the "argv-block".

This is the way ps worked in version 7, and probably still does in BSD.


					-=] Ford [=-

"Once there were parking lots,		(In Real Life:  Mike Ditto)
now it's a peaceful oasis.		ford@kenobi.cts.com
This was a Pizza Hut,			...!sdcsvax!crash!kenobi!ford
now it's all covered with daisies." -- Talking Heads