Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
Using fork() and the exec Set of Functions in OSS
In the OSS environment, you can use fork() and the exec set of functions as you would in the
UNIX environment, or you can use comparable versions of these functions that are HP extensions:
tdm_fork() and the tdm_execve set of functions. The OSS process-creation functions are similar
to their UNIX counterparts, except that creating processes in the OSS environment also gives the
processes Guardian attributes. Because OSS processes have Guardian attributes, Guardian
procedures can access, manage, and control OSS processes.
When you create OSS processes with fork() and the exec set of functions, the attributes of the
parent process are propagated to the child process, but the child process has an OSS process ID
that uniquely identifies it. An OSS process can send signals to and receive signals from other OSS
processes. In both UNIX and Open System Services, you can query and modify the process
environment using functions such as getpid() and putenv(). As in UNIX, OSS processes
receive notification when a child process terminates, with the SIGCHLD signal and using the
wait() and waitpid() functions.
The HP extension functions, tdm_fork() and the tdm_execve set, perform the same functions
as the OSS fork() function and the exec set of functions, except the HP extension functions use
these additional parameters:
• The pe_parms parameter points to an input structure, containing Guardian process attributes
to assign to the new process. The input structure is defined in the tdmext.h header file,
including default initialization values for this structure. The initialized values can then be
modified as appropriate for the call. Another argument is a pointer to an output structure,
which is defined along with its default initialization values in the tdmext.h header file.
• The pr_results parameter points to the output structure containing optional process
identification and error information. In case of an error, pr_results provides additional
information, including the PROCESS_LAUNCH_ error and error detail needed by some
Guardian management programs and procedures. These additional parameters bring more
interoperability and Guardian features to your programs.
With the HP extension functions, you can set or modify inherited Guardian attributes by specifying
values for the fields in the input structure that contains Guardian attributes. This modification cannot
be done with fork() and the exec set of functions in the UNIX environment or OSS environment.
For example, when creating a process with the tdm_fork() and tdm_execve() functions, you
can specify, with the tdm_execve() function call, the processor on which a process executes.
This capability allows you to distribute an application program across processors. You can also
specify the debug options to create a saveabend (or core or snapshot) file if the process terminates
abnormally.
You can create a child process across processors with a tdm_fork() function call by following
it with a call of one of the tdm_execve set of functions to another processor. The call to one of
the tdm_execve set of functions causes a child process to migrate to the second processor. (The
process making the tdm_fork() call and the process making the call to one of the tdm_execve
set of functions reside in the same program and processor.) The Open System Services Programmer’s
Guide includes an example of creating an OSS process with tdm_fork() and the tdm_execve
set of functions and details on managing OSS and Guardian processes.
However, to avoid the overhead of copying memory buffers across processors and initializing
extra processes, use the tdm_spawn set of functions instead. See “Using the tdm_spawn Set of
Functions for Load Leveling” (page 97) for more information on creating a process in another
processor.
Using the tdm_spawn Set of Functions for Load Leveling
Like fork() and the exec set of functions, the tdm_spawn set of functions creates a child process.
It performs generally the same operations as fork() and the exec set of functions, but in one
step. The tdm_spawn set of functions has the same extra input and output parameters (pe_parms
Using Process-Creation Calls 97