Open System Services System Calls Reference Manual (G06.28+)

System Functions (t) tdm_spawn(2)
envp[] Species an array of character pointers to null-terminated strings that describe
the environment for the new process.
pe_parms Points to the input structure containing Guardian process attributes to be
assigned to the new process. The structure is dened in the tdmext.h header le.
When this parameter contains a null pointer, the tdm_spawn() function assumes
default Guardian attributes. Otherwise, the structure must be dened locally and
initialized before its rst use. Initialization is done using the
#dene
DEFAULT_PROCESS_EXTENSION
,asdened in the tdmext.h header le.
The initialized values can then be modied as appropriate for the call.
pr_results Points to the output structure containing optional process identication and error
information. In case of error, this structure provides additional information,
including the PROCESS_LAUNCH_ procedure error and error detail. The struc-
ture is dened in the tdmext.h header le.
The structure must be dened locally and initialized before its rst use. Initiali-
zation is done by using the #dene
DEFAULT_PROCESS_EXTENSION_RESULTS,asdened in the tdmext.h
header le.
See the process_extension_results(5) reference page for information about the
content of the structure. The tdmext.h header le is not kept current when new
error codes are dened for process creation functions. The list of _TPC_ macros
described in that reference page is not complete; for a current description of error
macros and error codes, see the Guardian header le
$SYSTEM.ZSPIDEF.ZGRDC or the summary of process-creation errors in the
Guardian Procedure Calls Reference Manual (see the table entitled "Summary
of Process Creation Errors").
DESCRIPTION
The tdm_spawn() function creates a new process image. The new image is constructed from a
regular executable le, called a new process image le. The new process image le is formatted
as an executable text or binary le in one of the formats recognized by the tdm_spawn() func-
tion.
The tdm_spawn() function is similar to the tdm_spawnp() function. The main difference is the
way the pathname for the process image le is resolved. tdm_spawn() always resolves relative
pathnames by prexing the current working directory; see Identifying the Process Image File,
later in this reference page. tdm_spawnp() sometimes uses the PATH environment variable to
resolve pathnames.
The tdm_spawn() function provides a different way to create a new process than the way pro-
vided by the tdm_fork() and tdm_execve() functions. tdm_spawn() provides a more efcient
way to create a new process to execute a new program le. However, tdm_spawn() does not
provide all the function provided by tdm_fork() and tdm_execve().
When a program is executed as a result of a tdm_spawn() call, it is entered as a function call:
int main(
int argc,
char argv[],
char envp);
Here, the argc parameter is the argument count, the argv[]parameter is an array of character
pointers to the arguments themselves, and the envp parameter is a pointer to a character array
listing the environment variables. The argv[]array is terminated by a null pointer. The null
pointer is not counted in argc.
527186-005 Hewlett-Packard Company 841