Open System Services Programmer's Guide
Example 35 Getting Information About a Process Using PROCESS_GETINFOLIST_
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <cextdecs.h(PROCESS_GETINFOLIST_)>
short processhandle[10];
short attr_list[] = { /* list of attributes for which values are
to be returned */
21, /* real group ID */
22, /* real user ID */
80, /* effective group ID */
23, /* effective user ID */
90, /* OSS process ID */
94, /* OSS parent process ID */
26, /* OSS session leader ID */
98, /* OSS group leader PID */
27, /* OSS controlling terminal */
111, /* current size of native heap area */
112, /* maximum size of native heap area */
31, /* wait state */
32, /* process state */
48 /* process handle */
};
short attr_count; /* number of attributes */
short values_list[8000]; /* buffer of return values */
short values_len; /* size of return values information*/
short errordetail; /* additional error information */
short srch_option; /* search option */
short srch_attr_list[] = { 28 }; /* attribute code specifying search
criteria. 28 is process type (OSS
or Guardian). */
short srch_attr_count; /* number of search criteria */
short srch_values_list[1024]; /* buffer of return values */
short srch_values_len; /* size of return values */
char ctty[100]; /* controlling terminal */
pid_t osspid; /* OSS process ID */
int main(int argc, char *argv[]) {
int i, nbytes;
short retcode;
/* Get information for the process specified by the OSS process ID. */
if(argc > 1) {
osspid = atoi(argv[1]);
} else
osspid = getpid();
attr_count = (short)(sizeof(attr_list)/sizeof(short));
srch_option = 3; /* return info for process whose
OSS process ID is specified */
retcode = PROCESS_GETINFOLIST_(
, /* processor */
, /* process ident number (PIN) */
, /* node name */
, /* length of node name */
, /* process handle */
attr_list, /* attribute list to be returned */
attr_count, /* number of attributes */
values_list, /* list of output values */
1024, /* maximum number of values */
&values_len, /* length of list returned */
&errordetail, /* details of any errors */
134 Managing Processes