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/spawnlp.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/spawnlp.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/spawnlp.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/spawnlp.html on line 8

spawnlp()

Spawn a child process, given a list of arguments and a relative path

Synopsis:

#include <process.h>

int spawnlp( int mode, 
             const char * file, 
             const char * arg0, 
             const char * arg1..., 
             const char * argn, 
             NULL );

Arguments:

mode
How you want to load the child process, and how you want the parent program to behave after the child program is initiated:
file
The name of the executable file. If this argument contains a slash, it's used as the pathname of the executable; otherwise, the function searches for file in the directories listed in the PATH environment variable.
arg0, argn, NULL
The arguments that you want to pass to the new process. You must terminate the list with an argument of NULL.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The spawnlp() function creates and executes a new child process, named in file with NULL-terminated list of arguments in arg0 … argn. This function calls spawnvpe().


Note: 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 spawnlp() function isn't a POSIX 1003.1 function, and isn't guaranteed to behave the same on all operating systems. It builds an argv[ ] array before calling spawnp().

To view the documentation for a function, click its name in this diagram:

spawn spawnve spawnl spawnv spawnle spawnp spawnvpe spawnlpe spawnvp spawnlp

How the spawn functions are related


Most of the spawn*() functions do a lot of work before a message is sent to procnto.

Arguments are passed to the child process by supplying one or more pointers to character strings as arguments. These character strings are concatenated with spaces inserted to separate the arguments to form one argument string for the child process. At least one argument, arg0, must be passed to the child process. By convention, this first argument is a pointer to the name of the new child process.

The child process inherits the parent's environment. The environment is the collection of environment variables whose values that have been defined with the export shell command, the env utility, or by the successful execution of the putenv() or setenv() function. A program may read these values with the getenv() function.


Note: A parent/child relationship doesn't imply that the child process dies when the parent process dies.

Returns:

The spawnlp() 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).

Errors:

E2BIG
The number of bytes used by the argument 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 file exceeds PATH_MAX or a pathname component is longer than NAME_MAX.
ENOENT
The file identified by the file 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 spawnlp() function isn't implemented for the filesystem specified in file.
ENOTDIR
A component of the path prefix of the child process isn't a directory.

Classification:

QNX 4

Safety:
Cancellation point Read the Caveats
Interrupt handler No
Signal handler No
Thread Yes

Caveats:

If mode is P_WAIT, this function is a cancellation point.

See also:

execl(), execle(), execlp(), execlpe(), execv(), execve(), execvp(), execvpe(), getenv(), putenv(), setenv(), spawn(), spawnl(), spawnle(), spawnlpe(), spawnp(), spawnv(), spawnve(), 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/spawnlp.html on line 406

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/spawnlp.html on line 406