Creation process
pid_t getpid(void); //현재 pid 반환
pid_t getppid(void); //부모 pid 반환
pid_t fork(void); //child의 pid반환, child pid는 0
Running new program
- 성공시 리턴값은 없고 process 이동함. exec 뒤에 코드는 실행되지 않는다. 실패 시 -1리턴.
//실행 시킬 파일들을 list형태의 인자로 받음
int execl(const char *pathname, const char *arg0, …, NULL);
//실행 시킬 파일들 vector에 담아서 vector를 인자로 받음
int execv(const char *pathname, char *const argv[]);
//e: 환경변수. 실행 파일이 있는 경로 넣
int execle(const char *pathname, const char *arg0, …, NULL, char *const envp[]);
int execve(const char *pathname, char *const argv[], char *const envp[]);
//PATH에 등록된 경로에 있는 프로그램 파일 실행. 실행 파일 이름 넣음
int execlp(const char *filename, const char *arg0, …, NULL);
int execvp(const char *filename, char *const argv[]);