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