execl

Passes the name of an image to be activated in a child process. This function is nonreentrant.

Format

#include  <unistd.h>

int execl  (const char *file_spec, const char
           *arg0, . . . , (char *)0); (ISO POSIX-1)

int execl  (char *file_spec, . . . ); (Compatability)

Arguments

file_spec
The full file specification of a new image to be activated in the child process.
arg0, ...
A sequence of pointers to null-terminated character strings.

If the POSIX-1 format is used, at least one argument must be present and must point to a string that is the same as the new process file name (or its last component). (This pointer can also be the NULL pointer, but then execle would accomplish nothing.) The last pointer must be the NULL pointer. This is also the convention if the compatibility format is used.

Description

To understand how the exec functions operate, consider how the OpenVMS system calls any DEC C program, as shown in the following syntax:
int main (int argc, char *argv[], char
*envp[]);

The identifier argc is the argument count; argv is an array of argument strings. The first member of the array (argv[0]) contains the name of the image. The arguments are placed in subsequent elements of the array. The last element of the array is always the NULL pointer.

An exec function calls a child process in the same way that the run- time system calls any other DEC C program. The exec functions pass the name of the image to be activated in the child; this value is placed in argv[0]. However, the functions differ in the way they pass arguments and environment information to the child:

For other differences, see also execle, execlp, execv, execve, and execvp in this section.

If vfork was called before invoking an exec function, then when the exec function completes, control is returned to the parent process at the point of the vfork call. If vfork was not called, the exec function waits until the child has completed execution and then exits the parent process. See vfork in this section and Chapter 5 for more information.

Return Value
-1  Indicates failure. 


Previous Page | Next Page | Table of Contents | Index