The process of programming Linux Systems (iii) EXEC series functions and system functions

Source: Internet
Author: User

EXEC Replacement Process image

On the creation of a process UNIX employs a unique approach that separates process creation from loading a new process image. The advantage is that there is more room to manage both operations. When we create a process, we typically replace the subprocess with a new process image, which can be done using the EXEC series function. Of course, the Exec series functions can also replace the current process.

EXEC Association Function Group

Include header file <unistd.h>

function uses the EXEC function to replace the current process with a new process. exec name is a complete series consisting of multiple correlation functions, header file <unistd.h>

Prototype

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[]);

Parameters

The path parameter indicates that you want to start the program's name including the path name

The arg parameter represents the parameters that the startup program takes

Return value: Successfully return 0, failure return-1

The number of execl,execlp,execle (all with "L") is variable, and the argument ends with a null pointer.

The second argument for Execv, EXECVP, and EXECVPE is an array of strings that, when started, passes the arguments given in the argv array to the main

A function whose name contains the letter "P" searches the PATH environment variable to find the executable file for the new program. If the executable is not on path-defined paths, you must pass the absolute file name, including subdirectories, as a parameter to these functions.

A function with the last letter "E" of the first name can set the environment variable itself.

These functions are usually implemented with EXECVE, which is a common practice, not necessarily.

int Execve (const char *filename, char *const argv[], char *const envp[]);

Note that the first 6 functions are C library functions, and EXECVE is a system call.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.