Open System Services System Calls Reference Manual (G06.25+, H06.03+)
tdm_spawnp(2) OSS System Calls Reference Manual
When a program is executed as a result of a tdm_spawnp() 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.
The arguments specified by a program using the tdm_spawnp() function are passed on to the
new process image in the corresponding arguments to the
main() function.
Use From the Guardian Environment
If called from a Guardian process, the actions of this function are undefined, and errno is set to
[ENOTOSS].
Identifying the Process Image File
The tdm_spawnp() function uses the file parameter to identify the process image file. If the
pathname pointed to by the file parameter starts with a slash ( / ) character, it is the absolute path-
name. If the pathname does not start with a slash but contains a slash, the pathname is resolved
relative to the current working directory. Otherwise, the pathname does not contain a slash; the
system searches the directories listed in the PATH environment variable for the file and prefixes
the directory in which the file is found.
Passing the Arguments
The argv[]parameter is an array of character pointers to null-terminated strings. The last
member of this array is a null pointer. These strings constitute the argument list available to the
new process image. The value in argv[0] should point to a filename that is associated with the
process being started by the tdm_spawnp() function.
Specifying the Environment
The envp[]parameter is an array of character pointers to null-terminated strings. These strings
constitute the environment for the new process image. The environment array is terminated with
a null pointer.
The number of bytes available for the new process’s combined argument and environment lists
has a system-imposed limit. This limit, which includes the pointers and the null terminators on
the strings, is available by calling the sysconf(_SC_ARG_MAX) function.
Executing a Binary File
If the file specified as the new process image file is a binary executable file, the tdm_spawnp()
function loads the file directly.
Executing a Text File
If the file specified as the new process image file is not a binary executable file, the
tdm_spawnp() function examines the file to determine whether it is an executable text file. It
checks for a header line in this format:
#! interpreter_name [optional_string]
The #! notation identifies the file as an executable text file. The new process image filename is
constructed from the process image filename in the interpreter_name string, treating it like the
file parameter. The Guardian input and output structures pointed to by the pe_parms and
pr_results parameters apply to the command interpreter as they would to any process file.
The arguments passed to the new process are modified as listed:
8−58 Hewlett-Packard Company 527186-003