Unix/linux Process Detailed

Source: Internet
Author: User


Start a new process
Stdlib.h
Intsystem (const char *string)
Whichequals to "sh-c string"

Replace a process image
Unistd.h
Char**environ;
INTEXECL (const char *path, const char *arg0, ... (char *) 0);
INTEXECLP (const char *file, const char *arg0, ... (char *) 0);
Intexecle (const char *path, const char *ARG0,
                  ..., (char*) 0, char * const envp[]);
The number of parameters for these three functions is variable , The parameter ends with a null pointer. 


INTEXECV (const char *path, char *const argv[]);
INTEXECVP (const char *file, char *const argv[]);
The second parameter of these two functions is an array of strings, and when the new program starts, it will argv[] the parameters given in the array are passed to the Main function. 
Intexecve (const char *filename, char *const argv[], char *constenvp[]);
INTEXECVPE (const char *file, char *const argv[],char *const envp[]);

with the letter P the end of the function is searched by PATH environment variable to find the path to the new program's executable file. If the executable file is not  in path definition, you need to pass the file name with the absolute path, including the directory, as a parameter to the function. 
Global Variables environ you can pass a value to the new program environment. 
execle and the Execve you can pass parameters ENVP passes an array of strings as an environment variable for the new program. 

by exec class function starts the process, his parameter table and the total length of the environment together is limited Arg_max (posix> 4096b,linux = 128kb) . Error returning errno

Copy process image
To have the process execute multiple functions at the same time, you can use a thread or create a completely detached process from the source program (similar to Init )
Fork Copy the current process, create a new process and the original process is almost the same, but the new process has its own data space, environment, FD . used in conjunction with the exec function. 

Sys/types.h
Unistd.h

Pid_tfork (void);
Fork failed to return -1 , usually because the number of child processes used by the parent process is overrun ( Child_max), at which point errno is set to eagain  If the process table does not have enough space to create a new form or insufficient virtual memory,errno is enomem









Unix/linux Process Detailed

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.