System Interface Guide

exec(2)

exec is the name of a family of functions that includes execl, execv, execle, execve, execlp, and execvp. All load a new process over the calling process, but with different ways of pulling together and presenting the arguments of the function. For example, execl could be used like this


	execl("/usr/bin/prog2", "prog2", progarg1, progarg2, (char (*)0));

The execl argument list is:

/usr/bin/prog2

The path name of the new program file. 

prog2

The name the new process gets in its argv[0].

progarg1, progarg2

The arguments to prog2 as char (*)s.

(char (*)0)

A null char pointer to mark the end of the arguments. 

See execl(2) for more details.

There is no return from a successful execution of any variation of exec(); the new process overlays the process that calls exec. The new process also takes over the process ID and other attributes of the old process. If a call to exec fails, control is returned to the calling program with a return value of -1. You can check errno to learn why it failed.