home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / aix / 8021 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.4 KB  |  46 lines

  1. Path: sparky!uunet!olivea!hal.com!decwrl!purdue!mentor.cc.purdue.edu!mace.cc.purdue.edu!abe
  2. From: abe@mace.cc.purdue.edu (Vic Abell)
  3. Newsgroups: comp.unix.aix
  4. Subject: Re: Changing name associated with a process
  5. Message-ID: <54650@mentor.cc.purdue.edu>
  6. Date: 21 Jul 92 15:21:47 GMT
  7. References: <mwarren.711724488@rws1>
  8. Sender: news@mentor.cc.purdue.edu
  9. Lines: 35
  10.  
  11. In article <mwarren.711724488@rws1>, mwarren@rws1.ma30.bull.com (Mark Warren) writes:
  12. > We have a single executable ("foo" for the sake of discussion), which
  13. > forks several children, each of which has a different purpose.  I'd
  14. > like to change the name that is shown by 'ps' for each of these, so
  15. > that the 'ps' command display can give some hint of what they are
  16. > really doing.
  17.  
  18. The following works for me under AIX 3.2:
  19.  
  20.     main(int argc, char *argv[])
  21.     {
  22.             int i;
  23.     
  24.             i = strlen(argv[0]);
  25.             sprintf(argv[0], "%-.*s", i, "New");
  26.             for (;;)
  27.                     sleep(30);
  28.     }
  29.     speedy: 77 = a.out&
  30.     [1]     19884
  31.     speedy: 78 = ps
  32.        PID    TTY  TIME CMD
  33.      10925  pts/5  0:00 ps 
  34.      15217  pts/5  0:00 -ksh 
  35.      19884  pts/5  0:00 New 
  36.  
  37. However, the -u <user> option of ps(1) does ignore the change to argv[0].
  38.  
  39.     speedy: 79 = ps -u abe
  40.        UID   PID    TTY  TIME CMD
  41.        548 10926  pts/5  0:00 ps
  42.        548 15217  pts/5  0:00 ksh
  43.        548 19884  pts/5  0:00 a.out
  44.  
  45. Aren't you doing this already in your BSD environment?
  46.