Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)
and OSS process attributes can be specified when the new process is created or the new program
is executed.
tdm_fork() and the tdm_exec set of functions use the same parameters as fork() and the
exec set of functions, respectively, plus two new parameters. The first new parameter is a pointer
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. The second
new parameter is a pointer to an output structure, which is defined along with its default initialization
values in the tdmext.h header file.
Upon successful execution of tdm_fork() or the tdm_execve set of functions, the output structure
contains the Guardian process handle and OSS process ID (PID) of the created process. If the call
is not successful, detailed error information is included in the output structure. The default OSS
attributes and default Guardian attributes are inherited by the child process. Some Guardian
attributes that can be specified for the child process include process priority, processor number,
process name (system generated or programmer specified), home terminal, swap files, and debug
options.
Using the tdm_spawn Set of Functions
The tdm_spawn set of functions uses the same input parameters used by the tdm_execve set of
functions with the addition of two parameters. The first parameter specifies which file descriptors
that were open in the parent process remain open in the child process. The second parameter
points to an inheritance structure that specifies which OSS process attributes are inherited by the
child process, including default signals, signal mask, and process group.
Calling Guardian Procedures
Many of the more than 300 Guardian procedures can be called directly from an OSS C program
by including sections from the cextdecs.h header file in the source code of the program. You
must declare system procedures before calling them so the OSS C compiler generates the
appropriate interface code to call the Guardian system procedures. The cextdecs.h header file
contains function prototype declarations for the Guardian procedures that can be called directly
from a C program by specifying the C names for the procedures in uppercase characters and
providing a section for each procedure using the SECTION pragma.
The Guardian procedures require nonstandard C syntax to describe the interfaces. Code that calls
Guardian procedures needs to be compiled with the -Wextensions flag; for example:
c89 -Wextensions foo.c
Many Guardian procedures return values that can be used directly in a C program. Other Guardian
procedures use condition codes, such as TAL procedures returning _cc_status. You must include
the tal.h header file to use these Guardian procedures in your C program in the OSS environment.
See “Checking the Condition Code ” (page 175).
For those Guardian procedures which use structure declarations, the use of the appropriate header
files in your programs is strongly recommended.
The most commonly used header files are:
System data structures and literals/G/system/zsysdefs/zsysc
File system data structures and literals/G/system/zsysdefs/zfilc
System program interface data structures and literals/G/system/zsysdefs/zspic
To use Guardian procedures in your C program, you can specify only the names of the procedures
you want to include as section names. The following sample code demonstrates using Guardian
procedures in a C program:
Using HP Extensions 131