Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
tdm_spawn(2) OSS System Calls Reference Manual
EXAMPLES
This example uses the tdm_spawn( ) function to perform I/O redirection in a new process:
if ((NewStdOut = open ("newout", ...)) != -1)
/* process the error */
fd_map[0] = 0;
fd_map[1] = NewStdOut;
fd_map[2] = 2;
fd_count = 3;
tdm_spawn(..., fd_count, fd_map, ...);
close(NewStdOut);
This example creates a new process under a different user ID:
save = getuid();
setuid(newid);
tdm_spawn(...);
setuid(save);
RETURN VALUES
Upon successful completion, the tdm_spawn() function returns the OSS process ID of the child
process to the parent process. If the pr_results parameter does not contain a null pointer, it
returns the Guardian process handle of the new process in addition to the OSS process ID.
If the tdm_spawn() function fails, the value -1 is returned to the parent process, no child process
is created, and errno is set to indicate the error. If the pr_results parameter does not contain a
null pointer, the structure it points to returns additional error information, including the
PROCESS_LAUNCH_ error and error detail.
ERRORS
If any of the following conditions occurs, the tdm_spawn( ) function sets errno to the
corresponding value, file descriptors marked close-on-exec are not closed, signals set to be
caught are not set to the default action, and none of these are changed:
• The argv[] array of pointers
• The envp[ ] array of pointers
• The elements pointed to by these arrays
• The value of the global variable environ
• The pointers contained within the global variable environ
• The elements pointed to by environ pointers
• The effective user ID of the current process
• The effective group ID of the current process
[E2BIG] The number of bytes used by the new process image’s argument list and environ-
ment list is greater than the system-imposed limit. The limit can be obtained by
calling the sysconf(_SC_ARG_MAX) function.
[EACCES] One of these conditions exists:
• Search permission is denied for the directory components of the path-
name prefix to the process image file.
8−56 Hewlett-Packard Company 527186-023