Open System Services Programmer's Guide

For information about how to use these functions, see the Guardian Programmer’s Guide.
Examples in the following subsections show how to manage processes with both the OSS and
Guardian APIs. For information about OSS functions, see the Open System Services System Calls
Reference Manual and the Open System Services Library Calls Reference Manual. For information
about Guardian procedures, see the Guardian Procedure Calls Reference Manual.
Creating and Controlling Processes
The OSS API allows you to create OSS processes and to control (through signals functions) both
OSS and Guardian processes. The Guardian API provides procedures to create and control both
OSS and Guardian processes.
Using the OSS API
You can create only OSS processes with OSS functions. Both Guardian and OSS processes can
be controlled through signals functions with one exception: the kill() function. Only OSS
processes can send or receive signals using the kill() function, because kill() needs the
OSS process ID of the intended recipient in order to send a signal to it. (A Guardian process does
not have an OSS process ID.)
NOTE: You can use OSS signals functions with Guardian native processes; you cannot use them
with Guardian TNS processes.
Creating OSS Processes Using HP Extension Functions
The tdm_fork(), tdm_execve(), tdm_execvep(), tdm_spawn(), and tdm_spawnp()
functions allow you to set attributes when a process is created that you cannot set with the standard
fork() and exec set of functions.
You can create OSS processes using the tdm_spawn() or tdm_spawnp() function or by calling
the fork() or tdm_fork() function followed by one of the exec or tdm_exec set of functions.
Application performance is better if you use tdm_spawn() or tdm_spawnp(). These functions
also allow you to specify inheritance information for the child process in the inherit structure,
and the fd_count and fd_map parameters allow you to control the file descriptors the child
process inherits from the parent.
Examples of both methods of creating processes are shown for purposes of comparison.
Example 29 creates a named process with a system-generated name using tdm_fork(). The
program then passes a different process name and the processor on which the child process will
execute to tdm_execvep().
Creating and Controlling Processes 119