home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!decwrl!purdue!mentor.cc.purdue.edu!mace.cc.purdue.edu!abe
- From: abe@mace.cc.purdue.edu (Vic Abell)
- Newsgroups: comp.unix.aix
- Subject: Re: Changing name associated with a process
- Message-ID: <54650@mentor.cc.purdue.edu>
- Date: 21 Jul 92 15:21:47 GMT
- References: <mwarren.711724488@rws1>
- Sender: news@mentor.cc.purdue.edu
- Lines: 35
-
- In article <mwarren.711724488@rws1>, mwarren@rws1.ma30.bull.com (Mark Warren) writes:
- > We have a single executable ("foo" for the sake of discussion), which
- > forks several children, each of which has a different purpose. I'd
- > like to change the name that is shown by 'ps' for each of these, so
- > that the 'ps' command display can give some hint of what they are
- > really doing.
-
- The following works for me under AIX 3.2:
-
- main(int argc, char *argv[])
- {
- int i;
-
- i = strlen(argv[0]);
- sprintf(argv[0], "%-.*s", i, "New");
- for (;;)
- sleep(30);
- }
- speedy: 77 = a.out&
- [1] 19884
- speedy: 78 = ps
- PID TTY TIME CMD
- 10925 pts/5 0:00 ps
- 15217 pts/5 0:00 -ksh
- 19884 pts/5 0:00 New
-
- However, the -u <user> option of ps(1) does ignore the change to argv[0].
-
- speedy: 79 = ps -u abe
- UID PID TTY TIME CMD
- 548 10926 pts/5 0:00 ps
- 548 15217 pts/5 0:00 ksh
- 548 19884 pts/5 0:00 a.out
-
- Aren't you doing this already in your BSD environment?
-