Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 8
Spawn a child process, given a vector of arguments and an environment
#include <process.h>
int spawnve( int mode,
const char * path,
char * const argv[],
char * const envp[] );
- mode
- How you want to load the child process, and how you want the parent
program to behave after the child program is initiated:
- P_WAIT — load the child program into available
memory, execute it, and make the parent program resume execution after
the child process ends.
- P_NOWAIT — execute the parent program
concurrently with the new child process.
- P_NOWAITO — execute the parent program
concurrently with the new child process.
You can't use
wait()
to obtain the exit code.
- P_OVERLAY — replace the parent program with
the child program in memory and execute the child.
No return is made to the parent program.
This is equivalent to calling the appropriate exec*()
function.
- path
- The full path name of the executable.
- argv
- A pointer to an argument vector.
The value in argv[0] should represent the filename of
the program that you're loading.
The last member of argv must be a NULL
pointer.
The value of argv can't be NULL, and
argv[0] can't be a NULL pointer, even if you're
not passing any argument strings.
- envp
- NULL, or a pointer to an array of character pointers,
each pointing to a string that defines an environment variable.
The array is terminated with a NULL pointer.
Each pointer points to a character string of the form:
variable=value
that's used to define an environment variable.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The spawnve() function creates and executes a new child process,
named in path with the NULL-terminated list of arguments
in the argv vector.
|
If the new child process is a shell script, the first line must start with
#!, followed by the path of the program to run
to interpret the script, optionally followed by one argument.
The script must also be marked as executable.
For more information, see
“The first line”
in the Writing Shell Scripts chapter of the
Neutrino User's Guide. |
The spawnve() function isn't a POSIX 1003.1 function,
and isn't guaranteed to behave the same on all operating systems.
It calls spawn().
To view the documentation for a function, click its name in this diagram:
Most of the spawn*() functions do a lot of work before a message is sent to
procnto.
If the value of envp is NULL, then the child process
inherits the environment of the parent process.
The new process can access its environment by using the
environ
global variable (found in <unistd.h>).
The following arguments are passed to the underlying call
(spawn()):
- spawnve(mode, path, argv, envp)
- Create temporary attribute structure and set the flags member based on
the mode:
- 0 if mode = P_WAIT/P_NOWAIT
- SPAWN_EXEC if mode = P_OVERLAY
- SPAWN_NOZOMBIE if mode = P_NOWAITO
- Call spawn(path, 0, 0, attr, argv, envp).
|
A parent/child relationship doesn't imply that the child process dies when the parent process dies. |
The spawnve() function's return value depends on the mode argument:
mode
|
Return value
|
P_WAIT
|
The exit status of the child process.
|
P_NOWAIT
|
The process ID of the child process.
To get the exit status for a P_NOWAIT process, you must use the
waitpid() function,
giving it this process ID.
|
P_NOWAITO
|
The process ID of the child process, or 0 if the process is being started on a remote node.
You can't get the exit status of a P_NOWAITO process. |
If an error occurs, -1 is returned
(errno is set).
- E2BIG
- The number of bytes used by the argument list or environment list of the new child process
is greater than ARG_MAX bytes.
- EACCESS
- Search permission is denied for a directory listed in the path prefix
of the new child process or the new child process's file doesn't have the execute bit set.
- EAGAIN
- Insufficient resources available to create the child process.
- EBADF
- An error occurred duplicating open file descriptors to the new process.
- EFAULT
- One of the buffers specified in the function call is invalid.
- ELOOP
- Too many levels of symbolic links or prefixes.
- EMFILE
- Insufficient resources available to load the new executable
image or to remap file descriptors in the child process.
- ENAMETOOLONG
- The length of path exceeds PATH_MAX or a
pathname component is longer than NAME_MAX.
- ENOENT
- The file identified by the path argument is empty,
or one or more components of the pathname of the child process don't exist.
- ENOEXEC
- The child process's file has the correct permissions, but isn't in the correct format for an executable.
- ENOMEM
- Insufficient memory available to create the child process.
- ENOSYS
- The spawnve() function isn't implemented for the filesystem specified in path.
- ENOTDIR
- A component of the path prefix of the child process isn't a directory.
QNX 4
Safety: | |
Cancellation point |
Read the Caveats |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
If mode is P_WAIT, this function is a cancellation point.
execl(),
execle(),
execlp(),
execlpe(),
execv(),
execve(),
execvp(),
execvpe(),
getenv(),
putenv(),
setenv(),
spawn(),
spawnl(),
spawnle(),
spawnlp(),
spawnlpe(),
spawnp(),
spawnv(),
spawnvp(),
spawnvpe(),
wait(),
waitpid()
Processes and Threads
chapter of Getting Started with QNX Neutrino
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 421
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/spawnve.html on line 421