Open System Services Programmer's Guide
/* Reactivate the child process. */
retcode = PROCESS_ACTIVATE_
((short *)&proc_results.z_phandle,
);
if (retcode != 0) {
fprintf(stderr, "Process activate failure, code = %d\n",
retcode);
exit(1);
}
printf("Process %s activated for 10 seconds\n", proc_name);
sleep(10); /* wait ten seconds */
/* Terminate the child process. */
retcode = PROCESS_STOP_
((short *)&proc_results.z_phandle,
, /* process specifier */
, /* normal termination option */
, /* completion code */
, /* termination information */
, /* subsystem ID */
, /* text to be sent as part of process
termination system message */
/* message length */
);
if (retcode != 0) {
fprintf(stderr, "Process termination failure, code = %d\n",
retcode);
exit(1);
}
printf("Process %s terminated\n", proc_name);
exit(0);
}
Creating and Controlling OSS Processes
To create and control an OSS process using the Guardian API, you must use the PROCESS_SPAWN_
procedure. It creates an OSS process and can be called by both Guardian and OSS processes,
although it is most commonly called by Guardian processes, such as monitor programs, that must
manage both Guardian and OSS processes.
When the calling process is a Guardian monitor process pair, the monitor can ensure that an OSS
child process is restarted if it stops. In this way, the OSS child process is considered to be a
persistent process. Writing applications as persistent processes is one way to achieve
application-level fault tolerance.
PROCESS_SPAWN_ also allows you to create an OSS process in a nowait manner, which means
that the PROCESS_SPAWN_ procedure returns as soon as process creation is initiated. The calling
process continues processing while the child process is being created.
The process that calls PROCESS_SPAWN_ is a Guardian parent, regardless of whether it is an
OSS or Guardian process, and it receives process-termination notification through Guardian system
messages instead of the SIGCHLD signal. The parent process reads system messages from
$RECEIVE, which is a special file through which a process receives system messages or messages
from other processes. The created process is not the POSIX child of the created process.
Creating and Controlling Processes 125