The fork() function call immediately returns without finishing to create a process, thus printf(Child pid ..) is not called until it actually creates the process. printf( parent ...) is called right after return from the fork function call. The wait (&status) statement holds until the fork() system call finished, and printf(child pid ..) is called.
저 if문은 아래 exit 가 있는것을 보니 에러나는 경우에 프로그램을 종료 시키는것 같은데 if((pid = fork()) ==0) 구문이 fork 함수가 제대로 작동해서 자식을 생성했다면 0이 나오는게 당연하고 자식에 대한것을 print 한후에 종료 되겠는데요? 결론은 뭔가 책에 결과에 대한게 나오기엔 좀 이상한 코딩인거 같습니다.. 저는 리눅스에서 파이썬 가지고 DB 만지고 있는 초보DBA라 더 자세한건 다음 분이 설명해주실 겁니다. ㄷㄷ