Computers/Linux System Programming

ch8. process control

emzei 2013. 4. 28. 10:20

◆ getpid

#include<unistd.h>

 pid_t getpid(void);

(ret)  호출된 프로세스의 프로세스 id


◆ getppid

#include<unistd.h>

 pid_t getppid(void);

(ret)  호출된 프로세스의 부모 프로세스 id


◆ getuid

#include<unistd.h>

 uid_t getuid(void);

(ret)  호출된 프로세스의 실제 사용자 id


◆ geteuid

#include<unistd.h>

 uid_t geteuid(void);

(ret)  호출된 프로세스의 유효 사용자 id


◆ getgid

#include<unistd.h>

 gid_t getgid(void);

(ret)  호출된 프로세스의 실제 그룹 id


◆ getegid

#include<unistd.h>

 gid_t getegid(void);

(ret)  호출된 프로세스의 유효 그룹 id


◆ fork

#include<unistd.h>

 pid_t fork(void);

(ret)  success : 자식프로세스의 경우에는 0, 부모 프로세스의 경우 자식 프로세스의 id

   failed : -1






◆ vfork

#include<unistd.h>

 pid_t vfork(void);

(ret)  success : 자식프로세스의 경우에는 0, 부모 프로세스의 경우 자식 프로세스의 id

   failed : -1

 

 


 

 

 


◆ exit

#include<stdlib.h>

 void exit(int status);

 


◆ _Exit

#include<stdlib.h>

 void _Exit(int status);

 


◆ _exit

#include<unistd.h>

 void _exit(int status);

 


◆ atexit

#include<stdlib.h>

 int atexit(void (*function) (void));

(ret)  success : 0

   failed : -1


◆ on_exit

#include<stdlib.h>

 int on_exit(void (*function) (void));

(ret)  success : 0

   failed : -1


◆ wait

#include<sys/wait.h>

 pid_t wait(int *statloc);

(ret)  success :  프로세스 ID

   failed : 오류시 -1, 그 외의 경우 (?) 0


◆ waitpid

#include<sys/wait.h>

 pid_t waitpid(pid_t pid, int *statloc, int options);

(ret)  success : 프로세스 ID

   failed : 오류시 -1, 그외의 경우 0








◆ waitid

 

#include<sys/wait.h>

 int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options);

(ret)  success : 0

   failed : -1


 

◆ wait3

#include<sys/types.h>

#include<sys/wait.h>

#include<sys/time.h>

#include<sys/resource.h>

 pid_t wait3(int *statloc, int options, struct rusage *rusage);

(ret)  success : 프로세스 id

   failed : -1


◆ wait4

#include<sys/types.h>

#include<sys/wait.h>

#include<sys/time.h>

#include<sys/resource.h>

 pid_t wait4(pid_t pid, int *statloc, int options, struct rusage *rusage);

(ret)  success : 프로세스 id

   failed : -1








◆ execl

#include<unistd.h>

 int execl(const char *pathname, const char *arg0, ... /* (char *) 0 */ );

(ret)  success : 반환되지 않음

   failed : -1


◆ execv

#include<unistd.h>

 int execv(const char *pathname, char *const argv[]);

(ret)  success : 반환되지 않음

   failed : -1


◆ execle

#include<unistd.h>

 int execle(const char pathname, const char *arg0, ... /* (char *) 0, char *const envp[] */);

(ret)  success : 반환되지 않음

   failed : -1


◆ execve

#include<unistd.h>

 int execve(const char *pathname,  char *const argv[], char *const envp[]);

(ret)  success : 반환되지 않음

   failed : -1


◆ execlp

#include<unistd.h>

 int execlp(const char *filename, const char *arg0, ... /* (char *) 0 */);

(ret)  success : 반환되지 않음

   failed : -1


◆ execvp

#include<unistd.h>

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

(ret)  success : 반환되지 않음

   failed : -1





◆ setuid

#include<unistd.h>

 int setuid(uid_t uid);

(ret)  success : 0

   failed : -1


◆ setgid

#include<unistd.h>

 int setgid(uid_t uid);

(ret)  success : 0

   failed : -1


◆ setreuid

#include<unistd.h>

 int setreuid(uid_t ruid, uid_t euid);

(ret)  success :  0

   failed : -1


◆ setregid

#include<unistd.h>

 int setregid(gid_t rgid, gid_t egid);

(ret)  success : 0

   failed : -1



◆ setuid

#include<unistd.h>

 int seteuid(uid_t uid);

(ret)  success : 0

   failed : -1


◆ setgid

#include<unistd.h>

 int setegid(uid_t uid);

(ret)  success : 0

   failed : -1

 

 

 

 


 

 

◆ system

#include<stdlib.h>

 int system(const char *cmdstring);

(ret)   - cmdstring이 NULL 일 경우, 시스템이 명령 처리기를 제공한다면 system은 0 이 아닌 값을 반환

- system = fork + exec + waitpid

  * fork 실패 또는 waitpid가 EINTR 이외의 오류 반환 시, errno을 해당 값으로 설정하고 -1 반환

  * exec 실패 시, shell이 exit(127)을 호출할 때와 같은 값을 반환

  * 그 외의 경우 (fork, exec, waitpid 모두 성공) system의 반환값은 shell의 정지 상태
 

 


 





◆ getlogin

#include<unistd.h>

 char* getlogin(void);

(ret)  success : 로그인 이름을 담은 문자열을 가리키는 포인터

   failed : NULL


◆ times

#include<sys/times.h>

 clock_t times(struct tms buf);

(ret)  success : 소비된 클록 시간 값 (clock tick 수)

   failed : -1





'Computers > Linux System Programming' 카테고리의 다른 글

+ ch9. ( addition) process relationship  (0) 2013.05.20
ch9. process relationship  (0) 2013.05.20
ch7. process environment  (0) 2013.04.28
ch6. system data file and system information  (0) 2013.04.28
ch5. standard I/O library  (0) 2013.04.28