////////////////////////////////////////////////////////////////////////////// // Course: Real Time Systems // Lecturer: Dr.-Ing. Frank Golatowski // Exercise instructor: M.Sc. Michael Rethfeldt // Exercise: 1 // Task: 2 // Name: aufgabe2.c // Description: ? ////////////////////////////////////////////////////////////////////////////// #include #include #include #include int main(void) { int status; pid_t fork_pid; if ( (fork_pid=fork() ) == 0 ) { printf("* I am the son. *\n"); exit(3); } else if (fork_pid == -1) { printf("fork() failed!\n"); exit(2); } wait(&status); // wait for termination of son process // status: hexa decimal output from son process // (status>>8) & 0xff: second (higher byte) of the status // status & 0xff: first (lower byte) of the status printf("wait status: 0x%x | 0x%x | 0x%x |\n", status, (status>>8) & 0xff, status & 0xff); return 0; }