유닉스 환경에서 프로세스 동기화 하는 것에 대한 궁금중입니다.
가시
질문 제목 : 유닉스 환경에서 프로세스 동기화 하는 것에 대한 궁금중입니다.유닉스 환경에서 프로세스 동기화하는 방법에 대한
코드를 책에서 봤는데 이해가 안 가는 부분이 있어서 질문합니다.질문 내용 :
소스입니다.
#include sys/types.h
#include sys/wait.h
#include unistd.h
#include stdlib.h
#include stdio.h
int main()
{
int status;
pid_t pid;
switch(pid = fork())
{
case -1:
perror(fork);
exit(1);
break;
case 0: /* child process */
printf (--child process \n);
exit(2);
break;
default: /* parent process */
while (wait(&status) != pid)
continue;
printf (--parent process \n);
printf (status : %d %x \n, status, status);
printf (child process exit status: %d \n, status 8);
break;
}
return 0;
}
위의 소스에서 자식 프로세스의 exit(2)의 값이 status 로 전달되는 것 같던데
소스상에서는 전달되는 부분이 없는 것 같은데 어떻게 전달되는건지가 궁금합니다.