exec
Prototype:
#include <unistd.h>
int execve(const char* path, char* const argv[], char* const envp[]);
int execl(const char* path, const char* arg, ...);
int execlp(const char* file, const char* arg, ...);
int execle(const char* path, const char* arg, ..., char* const envp[]);
int execv(const char* path, char* const argv[]);
int execvp(const char* file, char* const argv[]);
General Description: Run an external program (either a binary or an executable script with "#! <interpreter> [arg]" in the first line). This call replaces the currently running task with the external program's context. The new program keeps the caller's PID and open files. The calls execl(), execlp(), execle(), execv(), and execvp() are all front ends to execve().
Return Value: This call does not return if successful. If it fails, the return value is -1.
Parameters
file The program to execute. The call searches for the name in this variable using the defined PATH.
path The absolute path and filename of the program to execute.
argv The string array of command line parameters. The first array element value must be arg0 (or the name of the program). The last array element is always zero (0).
arg A command line parameter. This is followed by an ellipsis (...) to indicate that there are several arguments. The first arg is always the name of the program, and the last arg is always zero (0).
envp The string array of environment parameters. Each parameter is in the form of <param>=<value> (for example: "TERM=vt100"). The last array element is always zero (0).
Possible Errors
EACCES The file or a script interpreter is not a regular file. -OR- Execute permission is denied for the file or a script interpreter. -OR- The file system is mounted noexec.
EPERM The file system is mounted nosuid, the user is not the superuser, and the file has an SUID or SGID bit set.
EPERM The process is being traced, the user is not the superuser and the file has an SUID or SGID bit set.E2BIGThe argument list is too big.
ENOEXEC An executable is not in a recognized format, is for the wrong architecture, or has some other format error that means it cannot be executed.
EFAULT The filename points outside your accessible address space.
ENAMETOOLONG The filename is too long.
ENOENT The file filename or a script or ELF interpreter does not exist.
ENOMEM Insufficient kernel memory was available.
ENOTDIR A component of the path prefix of filename or a script or ELF interpreter is not a directory.
EACCES Search permission is denied on a component of the path prefix of filename or the name of a script interpreter.
ELOOP Too many symbolic links were encountered in resolving filename or the name of a script or ELF interpreter.
ETXTBUSY Executable was open for writing by one or more processes.
EIO An I/O error occurred.
ENFILE The limit on the total number of files open on the system has been reached.
EMFILE The process has the maximum number of files open.
EINVAL An ELF executable had more than one PT_INTERP segment (i.e., tried to name more than one interpreter).
EISDIR An ELF interpreter was a directory.
ELIBBAD An ELF interpreter was not in a recognized format.
Examples
execl("/bin/ls", "/bin/ls", "-al", "/home", "/boot", 0);
perror("execl() failed"); /* No IF needed here: if successful, no return */

char *args[]={"ls", "-al", "/home", "/boot", 0};
execvp(args[0], args);
perror("execvp() failed");