1 #include <stdio.h> 2 #include <unistd.h> 3 #include <stdlib.h> 4 5 6 int main() 7 { 8 /*fork一个子进程*/ 9 pid_t pid = fork(); 10 if(pid>0){ 11 printf("in parent process,sleep for one miniute...zZ... "); 12 sleep(3); 13 printf("after sleeping, and exit! "); 14 } 15 else if(pid == 0){ 16 /*子进程退出,成为一个僵尸进程*/ 17 printf("in child rocess,and exit! "); 18 exit(0); 19 } 20 return 0; 21 }