agq@itd1.dsto.oz (Ashley Quick) (12/13/90)
John Thompson has shown the extended proc2_$ info list.
Here is a bit more juicy stuff for those who wish to name processes.
No doubt this has been listed before... but here goes.
There are two calls for naming processes:
pm_$set_my_name will name the current process
pm_$set_name will name a process by UID
Note that there are also calls to get a process name, of the
form "pm_$get_name", but I have not looked into those.
One thing to remember: these calls ARE NOT SUPPORTED, by HP/Apollo
or me or anybody else. Use at your own peril!
Here is a rather untidy example... you will need to play with it
a little....
---------------------------- 8< 8< 8< ------------------------------
/* Name processes - templates, etc for the pm_$ calls */
#include <apollo/base.h>
#include <apollo/pgm.h>
#include <apollo/pfm.h>
#include <apollo/error.h>
#include <apollo/proc2.h>
/*********************************************************************
* Set the name of the calling process. *
* This call is NOT provided as part of the DOMAIN/OS user callable *
* system support. It does, however, work! *
*********************************************************************/
void pm_$set_my_name(char *proc_name,
unsigned short &name_len,
status_$t *status);
/*********************************************************************
* Set the name of a process by UID *
*********************************************************************/
void pm_$set_name(char *proc_name,
unsigned short &name_len,
uid_$t *uid,
status_$t *status);
static void check(status_$t s_status)
{
if (s_status.all != status_$ok)
{
error_$print(s_status);
pfm_$error_trap(s_status);
pgm_$exit();
}
}
main()
{
status_$t status;
uid_$t uid;
char dummy[100];
/* Uncomment this section and see that the process gets named */
/* pm_$set_my_name("test",4,&status);
check(status);
*/
gets(dummy); /* wait so you can do a "pst" */
/* find the uid of this process and name it. If already named, this
will error - so comment out the call above */
proc2_$who_am_i(&uid);
pm_$set_name("fred", 4, &uid, &status);
check(status);
gets(dummy); /* wait so you can do a "pst" */
}
------------------------- 8< 8< 8< -------------------------------------
One wee note: it is a little hard to enter HEX UIDs into C code!!!
I can forsee a program which took a uid from the command line
and named a process...... That would not be very hard....
Ashleigh Quick
AGQ@dstos3.dsto.oz.au
Ashleigh Quick | ACSnet: AGQ@dstos3.dsto.oz
Defence Science and Technology Organisation| Internet: AGQ@dstos3.dsto.oz.au
PO Box 1600 | Phone: (Intl) (+61 8) 259 6975
Salisbury 5108 AUSTRALIA | (Local) (08) 259 6975