System Calls

exec

  • A libc implementation / POSIX contains six exec functions that wrap the execve system call.

  • An l following exec means the function accepts args as a (vararg) list of pointers to strings.

  • An v following exec means the function accepts args as a vector/array of pointers to strings.

  • p functions check PATH to find the executable in question.

  • e functions allow passing in environment variables.

  • Why is there no execlpe? 🤔

  • Here are the six functions:

    • int execl(const char *pathname, const char *arg, ... /*, (char *) NULL */);

    • int execlp(const char *file, const char *arg, ... /*, (char *) NULL */);

    • int execle(const char *pathname, const char *arg, ... /*, (char *) NULL, char *const envp[] */);

    • int execv(const char *pathname, char *const argv[]);

    • int execvp(const char *file, char *const argv[]);

    • int execvpe(const char *file, char *const argv[], char *const envp[]);

Edit