changing cmd listing for ps -f

Stephen J. Friedl friedl at mtndew.UUCP
Thu Jul 5 14:35:40 AEST 1990


In article <1793 at necisa.ho.necisa.oz>, boyd at necisa.ho.necisa.oz (Boyd Roberts) writes:
> Nothing you do on System V will change the command name/argument list
> that ps prints.  Both the command name and some of the `arguments' are
> stored in the U area and are not modifiable by any `reliable' method.

The industrious can find an unreliable but fun method.  At the
start of your program, make a pipe.  Write all your real args
down the pipe and then modify the arg list to taste but with some
magic word as argv[0] so the program knows that it's on the
second round.  I usually use the empty string.  Then close the
write half of the pipe and exec yourself (finding your own name
could be hard).

On the second round you look for the magic token in argv[0].  If
found, open /dev/null and then close it again: the read pipe will
be one less than the descriptor returned.  Read all your args
from it and stick them back in whatever argv you want to work
with, close the pipe, and continue.

Now ps will show the arglist you want.

Yes, it is an unreliable hack but I felt kind of clever when I
thought of it :-)

     Steve

-- 
Stephen J. Friedl, KA8CMY / Software Consultant / Tustin, CA / 3B2-kind-of-guy
+1 714 544 6561  / friedl at mtndew.Tustin.CA.US  / {uunet,attmail}!mtndew!friedl

"Show me a good loser and I'll show you a loser" - Roger Penske



More information about the Comp.unix.wizards mailing list