|
The exec functions of Unix-like operating systems are a collection of functions that causes the running process to be completely replaced by the program passed as argument to the function. As a new process is not created, the process ID (PID) does not change across and execute, but the data, heap and stack of the calling process are replaced by those of the new process. In the execl, execlp, execv, and execvp calls, the child process inherits the parent's environment. Files open when an exec call is made remain open in the new process. All open files must be flushed before an exec call. The exec calls do not preserve the translation modes of open files. If the child process uses files inherited from the parent, setmode function can be called to set the translation mode to the desired mode. In MS-DOS environments, a program executed with one of the exec functions is always loaded into memory as if the "maximum allocation" in the program's executable file header is set to default value 0xFFFF. The EXEHDR utility can be used to change the maximum allocation field of a program. However, if this is done and the program is invoked with one of the exec functions, the program might behave differently from a program invoked directly from the operating-system command line or with one of the spawn functions. Many Unix shells also offer an "exec" built-in command that replaces the shell process with the specified program.[1] "Wrapper" scripts often use this command to run a program (either directly or through an interpreter or virtual machine) after setting environment variables or other configuration. By using exec, the resources used by the shell program do not need to stay in use after the program is started. [2]
PrototypesThe functions are declared in
Function namesThe base of each function is exec, followed by one or more letters:
PathThe arg0The first argument EnvpArgument Each null-terminated string has the form:
where Return ValueThe exec functions do not normally return to the calling process. If an exec function returns, an error occurred, the return value is -1, and errno is set to one of the following values:
See alsoReferences
External links
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net