Open System Services Programmer's Guide
fdentry[2].z_dupfd = -1;
fdentry[2].z_name = errpath;
fdentry[2].z_oflag = O_RDWR;
fdentry[2].z_mode = 0755;
/* Dummy inheritance structure */
inherit.flags = 0;
/* Build program argument list */
pargv[0] = progname;
if(argc <= 2)
pargv[1] = NULL;
else /* copy command arguments */
while(pargv[i] = argv[i+1])
i++;
/* Assign search PATH string based on whether the program/process is
be run on a remote system or a local system */
if(remote)
pathstring = "/E/native/bin:/E/native/usr/bin:/E/native/usr/local/bin";
else
pathstring = "/bin:/usr/bin:/usr/local/bin";
/* Create the new OSS process and run program */
pid = PROCESS_SPAWN_(
progname, /* OSS pathname of program to be run */
fdinfo, /* file descriptor information structure */
pargv, /* pointer to argument strings */
environ, /* pointer to array of addr. of env. values */
&inherit, /* inheritance structure */
sizeof(inherit), /* length of structure */
&proc_ext, /* process extension structure */
&proc_results, /* process results structure */
, /* nowait tag (not used in this example) */
pathstring /* use PATH search string */
);
/* If unsuccessful, print out error message and exit */
if (pid == -1) {
fprintf(stderr, "OSS errno = %d\n", proc_results.pr_errno);
fprintf(stderr, "Guardian error = %d\n", proc_results.pr_TPCerror);
fprintf(stderr, "Error detail = %d\n", proc_results.pr_TPCdetail);
exit(1);
}
/* Wait for death of child process */
MONITORCPUS(-1); /* Request CPU status messages */
if (error = FILE_OPEN_(recvname, (short)strlen(recvname), &recvfile))
exit(1);
/* Read system messages on $RECEIVE */
do {
READX(recvfile, (char *)&msg.msgcode, (short)sizeof(msg));
FILE_GETINFO_(recvfile, &error);
} while (!error
|| error == 6 /* system message */
&& !(msg.msgcode == ZSYS_VAL_SMSG_PROCDEATH /* death message */
&& msg.procdeath.z_osspid == pid /* process ID match */
&& msg.procdeath.z_completion_code
!= ZSYS_VAL_PROCDEATH_CHILDEXEC) /* completion code */
&& !(msg.msgcode == ZSYS_VAL_SMSG_CPUDOWN /* CPU down message check*/
&& !valid_pid(pid))); /* child process ID invalid*/
printf("Child process terminated\n");
exit(0);
}
Querying the Process Environment
The OSS API and the Guardian API both allow you to get information about both OSS and Guardian
processes and their environments.
Querying the Process Environment 129