Process Control (10)---exec family functions

Source: Internet
Author: User

when a child process is created using fork (), the Exec family function is typically used to specify a new program to overwrite the child process's code snippet, data segment, heap, and stack. This allows the child process to execute a new program instead of executing a copy of the parent process. =====================================================There are a total of 6 functions in the Exec family function:The above 5 functions belong to the library function, these functions are finally called the following Execve function, the 6 functions, only the EXECVE function belongs to the system call of Linux. Error returned:
    • These functions do not return when the call succeeds, only return 1 if an error is called
====================================================The difference between these functions (distinguished by the function name):
    • (list) with L: means that command-line arguments are given as separate arguments
    • V (vector): means that command-line arguments are given as an array of character pointers
    • With P (path): means to search the PATH environment variable for the given file name, (of course, if the path name of the given file is also possible, only given the filename of the time will go to the path variable to find)
    • Without p: means that the full executable file name must be given
    • (Environment) with E: means passing new environment variables to the executable file
    • Without e: means not passing environment variables, using environment variables copied from the parent process
=======================================================when calling the Exec family function to have the new program overwrite the code snippet, data segment, and stack of the original process:
    • Does not create a new process, the process ID and parent process ID of the process remain unchanged, and the parent-child relationship is not changed by invoking the Exec family function.
    • The file descriptors that are copied from the parent process in the child process are not closed by default and are still available in the new program. The CLOSE-ON-EXEC flag is closed unless the FCNTL function is called.
    • The Open Directory stream is closed because the OPENDIR function is implemented, and the Opendir function opens the CLOSE-ON-EXEC flag.
    • The actual user ID is constant, the valid user ID is determined according to the new executable file, if the new executable file set the Set-user-id bit, then the valid user ID will be set to the user ID of the file, or the valid user ID to maintain the original child process valid user ID is unchanged.

Process Control (10)---exec family functions

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.