[네트워크프로그래밍]fork() 함수 이용한 simple program
#include #include #include #include int main(){ pid_t pid, child; int a = 5, b = 3; int state; pid = fork(); if(pid == 0){ b += 1; printf("Child process id = %d\n", getpid()); printf("a = %d, b = %d\n", a, b); sleep(10); } else{ do{ a += 1; sleep(3); puts("\n3 sec wait\n"); child = waitpid(pid,&state, WNOHANG); }while(!child); } printf("child proess id = %d\n return value = %d\n",child, a*b); re..