Open System Services Programmer's Guide
Example 37 Modifying Information About the Current Process Using PROCESS_SETINFO_ and
PROCESS_SETSTRINGINFO_
/* Modifying info about the current process using PROCESS_SETINFO_ and */
/* PROCESS_SETSTRINGINFO_ (works on H-series RVUs only) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cextdecs.h(PROCESS_SETINFO_,PROCESS_SETSTRINGINFO_)>
short priority = 150;
short oldpriority, oldvaluelen;
char *hometerm;
int main(int argc, char *argv[]) {
short retcode;
/* Get name of home terminal from command line.
If none provided, use default setting. */
if (argc > 1)
hometerm = argv[1];
else
#ifdef _TNS_E_TARGET
hometerm = "$ZTNT.#PTY00D4" ; /* Note 1 */
#else
hometerm = "$ZTN0.#PTY00D4" ; /* Note 1 */
#endif
/* Set process execution priority to a specified value. */
retcode = PROCESS_SETINFO_(
, /* process handle of current process */
, /* process specifier */
(short)42, /* current priority attribute code */
&priority, /* priority value */
(short)1, /* length of value (short) */
&oldpriority, /* returned value of priority */
(short)1,
&oldvaluelen /* length of returned value */
);
/* If unsuccessful, print error message and exit. */
if (retcode != 0) {
fprintf(stderr, "retcode = %d\n", retcode);
exit(1);
}
printf("Current process priority set to %d\n", priority);
/* Set process home terminal to new value. */
retcode = PROCESS_SETSTRINGINFO_(
, /* process handle of current process */
, /* process specifier */
5, /* home terminal attribute code */
hometerm, /* new home terminal string value */
(short)strlen(hometerm), /* length of string */
);
/* If unsuccessful, print error message and exit. */
if (retcode != 0) {
fprintf(stderr, "retcode = %d\n", retcode);
exit(1);
}
printf("Home terminal set to %s\n", hometerm);
exit(0);
}
Modifying the Process Environment 137