Open System Services Porting Guide (G06.24+, H06.03+)

Table Of Contents
OSS Porting Considerations
Open System Services Porting Guide520573-006
6-14
Using fork() and the exec Set of Functions in OSS
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