Open System Services Programmer's Guide
Example 34 Getting Information About a Process Using PROCESS_GETINFO_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <cextdecs.h(FILENAME_TO_PROCESSHANDLE_,\
PROCESS_GETINFO_,PROCESSHANDLE_GETMINE_)>
short processhandle[10];
short mom_processhandle[10];
short gmom_processhandle[10];
short fnlen, priority, htlen, caid, paid, jobid, proglen, swaplen;
short errordetail;
long long proc_time;
char proc_fname[64];
char hometerm[64];
char programfile[64];
char swapfile[64];
short proctype;
long osspid;
int main(int argc, char *argv[]) {
short retcode;
/* Get the process name from the command line. If not supplied, use the
current process. Use the process name to get the process handle. */
if(argc > 1) {
retcode = FILENAME_TO_PROCESSHANDLE_(
argv[1], /* process filename */
(short) strlen(argv[1]), /* length of process filename */
processhandle /* process handle */
);
if(retcode != 0) {
fprintf(stderr, "Invalid process name %s\n", argv[1]);
exit(1);
}
} else {
printf("Using current process\n");
retcode = PROCESSHANDLE_GETMINE_(processhandle);
if (retcode != 0) {
fprintf(stderr, "Can't get current process handle\n");
exit(1);
}
}
/* Get process information and print the values. */
retcode = PROCESS_GETINFO_(
processhandle, /* process handle */
proc_fname, /* process filename */
64, /* maximum length */
&fnlen, /* length of filename */
&priority, /* current execution priority */
mom_processhandle, /* process handle of MOM process */
hometerm, /* home terminal */
64, /* maximum length */
&htlen, /* length of hometerm name */
&proc_time, /* execution time in usec */
&caid, /* creator access ID */
&paid, /* process access ID */
gmom_processhandle, /* process handle of GMOM */
&jobid, /* job ID */
programfile, /* program filename */
64, /* maximum length */
&proglen, /* length of program filename */
132 Managing Processes










