#include #include #include #include // wait #include // pid_t int main () { pid_t pid, wait_pid; pid = fork(); if (pid<0) perror ("fork"), exit(1); if (pid==0) { printf ("Child: My PID is %d\n", (int)getpid()); exit(0); } else { printf ("Parent: My PID is %d\n", (int)getpid()); // Neu: warte zuerst auf das Ende des Kindprozesses wait_pid = wait(NULL); if(wait_pid < 0) perror("wait"), exit(2); sleep(30); } return 0; }