Execve


Execve is a system call to the UNIX operating system, standardized on the POSIX standard and others.

Your prototype is as follows (in C programming language): int execve (const char *filename, const char *argv [], const char *envp[]);

execve executes the program indicated by filename. filename must be an executable binary, or a shell script starting with a line of the form "#! interpreter [arg]" (known as shebang). In the second case, the interpreter must be a valid path name for an executable that is not itself a script and will be executed with the [arg] (optional) arguments plus the filename file to be interpreted.

argv is an array of argument strings passed to the new program. envp is an array of strings, conventionally of the form key = value, that are passed as environment to the new program. Both argv and envp must end in a null pointer. The argument vector and the environment can be accessed by the main function of the invoked program when it is defined as int main (int argc, char * argv [], char * envp []).

execve does not return on success, and the code segment, data segment, BSS, and stack of the invoking process are overwritten with corresponding ones of the loaded program. The invoked program inherits the PID of the invoking process and any open file descriptors that have not been set to "close on exec". The pending signals from the invoking process are cleared. Any signal captured by the calling process is returned to its default behavior.

wiki

Popular Posts