/**************************************/ /* */ /* Prof. Dr. Carsten Vogt */ /* TH Koeln, Fakultaet IME */ /* http://www.nt.th-koeln.de/vogt */ /* */ /* UNIX-C-Schnittstelle: */ /* exit() und wait() */ /* */ /**************************************/ #include #include #include #include int main() { int status; printf("\n"); if (fork()==0) { sleep(1); printf("Sohn: exit(0)\n\n"); exit(0); } wait(&status); printf("Vater: status = %d\n\n",status); printf("Vater: WEXITSTATUS(status) = %d\n\n",WEXITSTATUS(status)); printf("\n"); if (fork()==0) { sleep(1); printf("Sohn: exit(1)\n\n"); exit(1); } wait(&status); printf("Vater: status = %d\n\n",status); printf("Vater: WEXITSTATUS(status) = %d\n\n",WEXITSTATUS(status)); }