Here are the standard exec*
functions:
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[]);
int execvpe(const char *file, char *const argv[], char *const envp[]);
It's the Unix convention to pass the program name to be executed as the first member of the argument array.
In what realistic context(s) (if any) does it make sense to diverge from the convention and not make path/file the same as arg/argv[0]?
argv[0]
to choose what program to act like, literally every traditional shell usesargv[0][0] == '-'
as a way to know if it needs to act like a login shell, etc), but this was also probably one of the first uses of the zeroth argument, and is probably actually one of the reasons for why the zeroth argument exists - whereas theps
thing is a modern hack poorly working around a modern problem. – mtraceur Jul 05 '21 at 00:13