Here is a table to summarize all seven of the exec family APIs:
Exec API | Arguments: long format (l) | Arguments: short format (v) | PATH searched? (p) | Environment passed? (e) | API layer |
execl |
Y |
N |
N | N | Lib |
execlp | Y | N | Y | N | Lib |
execle | Y | N | N | Y | Lib |
execv | N | Y | N | N | Lib |
execvp | N | Y | Y | N | Lib |
execvpe | N | Y | Y | Y | Lib |
execve | N | Y | N | Y | SysCall |
The exec APIs format: exec<foo>, where <foo> is differing combinations of {l,v,p,e}.
All the listed APIs, on success, as we have learned, do not return at all. Only upon failure, would you see a return value; as per the usual norms, the global variable errno will get set to reflect the cause of the error, which can be conveniently looked up via the perror(3) or strerror(3) APIs (as an example, within the book's provided source code, check out the FATAL macro within the common.h header file).