krowitz%richter@UMIX.CC.UMICH.EDU (David Krowitz) (12/14/89)
I've noticed that a number of Apollo supplied programs manage to their process names (the ones shown by /com/pst) no matter what name you use when you start the program. Anyone have any idea how this is accomplished? -- David Krowitz krowitz@richter.mit.edu (18.83.0.109) krowitz%richter.mit.edu@eddie.mit.edu krowitz%richter.mit.edu@mitvma.bitnet (in order of decreasing preference)
lampi@pnet02.gryphon.com (Michael Lampi) (12/15/89)
The names of the processes are entered in `node_data/proc_dir. If you change
the names in this directory, you change the name displayed by /com/pst.
Michael Lampi MDL Corporation 213/782-7888 fax 213/782-7927
UUCP: {ames!elroy, <routing site>}!gryphon!pnet02!lampi
INET: lampi@pnet02.gryphon.com
"My opinions are that of my corporation!"holtz@cascade.carleton.CDN (Neal Holtz) (12/15/89)
To set the name of a process (in SR9.7), we use the following
C procedure, which uses an undocumented system call. The procedure
tries 25 (or is it 26) times to set the name, appending a numeric count
to the name when a process of the desired name already exists.
#####################################################################
/*
* set the name of this process
*/
int Name_process( pn )
char *pn; /* the desired process name */
{
std_$call pm_$set_my_name(); /* undocumented, but handy */
typedef long stat_$t; /* status codes returned */
stat_$t st;
stat_$t exists = 0x800E0003; /* if process already exists */
int cnt = 0; /* to append to name */
char buf[100];
strcpy( buf, pn );
pm_$set_my_name( buf, (short)strlen(buf), st );
while( st == exists && cnt < 25 ) {
sprintf( buf, "%s.%d", pn, cnt++ );
pm_$set_my_name( buf, (short)strlen(buf), st );
}
return( st == 0 );
}dbfunk@icaen.uiowa.edu (David B Funk) (12/15/89)
WRT posting <8912131818.AA18099@richter.mit.edu>: > I've noticed that a number of Apollo supplied programs > manage to their process names (the ones shown by /com/pst) > no matter what name you use when you start the program. > Anyone have any idea how this is accomplished? By this I assume that you're refering to something like: 1) You start a process with the DM "cps" or a "crp -cps" command such as: "Command: cps /sys/ncs/llbd -n my_name" (sr9.7) 2) You then do a "/com/pst" and see: ... 34246.796 3/14/14 3B416592 Wait tcp_server 42.164 3/14/14 3B416072 Wait netman 32.812 3/13/14 3B416592 Wait process_333 1307.390 3/14/14 3B416592 Wait ns_helper 10.636 3/14/14 3B416592 Wait llbd 0.123 3/14/14 3B416592 Wait message ... And you notice that "my_name" is gone and that "llbd" is now there. Here's what is happening; The name that you gave to the process during the process creation was OK, but the program was written so that it did some stuff and then did a Unix "fork" to create a new copy of itself. The parent process (the one that you started and named) then exited and the new child process was un-named so it was free to set its own name with the "set my name" system call. A program usually does the "fork" trick when it wants to do things like change the standard streams around or detach itself from the controlling "tty" or if it's a "set-uid" program. BTW don't try to go changing the names that you find in `node_data/proc_dir. This can cause problems/confusion and under sr10, you can see named processes with pst and find no entry for them in `node_data/proc_dir. Dave Funk