This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ﬁle filename with the argument list argv and the environment variable list envp. Execve returns to the calling program only if there is an error such as not being able to ﬁnd filename. So unlike fork, which is called once but returns twice, execve is called once and never returns. The argument list is represented by the data structure shown in Figure 8.17. The argv variable points to
argv argv argv argv ... argv[argc-1] NULL "ls" "-lt" "/usr/include" Figure 8.17: Organization of an argument list. a null-terminated array of pointers, each of which points to an argument string. By convention argv is the name of the executable object ﬁle. The list of environment variables is represented by a similar data structure, shown in Figure 8.18. The envp variable points to a null-terminated array of pointers to environment variable strings, each of which is a name-value pair of the form ”NAME=VALUE”. After execve loads filename, it calls the startup code described in Section 7.9....
View Full Document