#include<stdio.h> #include<unistd.h> int main() { pid_t pid,pid1; int status; if( (pid = fork())<0) { printf("fork error "); return -1; } else if( pid == 0) { printf("%d,%d ",getpid(),getppid()); if( (pid1 = fork())<0) { printf("fork error "); return -1; } else if(pid1 == 0) { printf("%d,%d ",getpid(),getppid()); system("ps -ef|grep dlsc30"); return 0; } exit(0); } wait(&status); printf("%d,%d ",getpid(),getppid()); while(1) { printf("i will not break "); sleep(5); } exit(0); }