Sample

xiaoxiao2021-03-06  40

#include #include #include int main () {pid_t pid = 0; if ((pid = fork ())> 0) Printf ("I am the Parent , My PID% U, My Child's PID =% u / n ", getPID (), PID); ELSE IF (PID == 0) Printf (" I am the child, my pid =% u, my parent's id =% U / N ", getPID (), getppid ()); else {perror (" fork "); return 1;} return 0;}

转载请注明原文地址:https://www.9cbs.com/read-77370.html

New Post(0)