Skip to content

Commit

Permalink
Fixes smuos#8. Use correct fork() return codes in switch.
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Sep 16, 2014
1 parent e721a64 commit 34b08b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fork1.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ main(int argc, const char** argv)
// Could not cut another process
fprintf(stdout, "OS too hard, could not cut.\n");
exit(0);
} else if (rc == 1) {
} else if (rc == 0) {
fprintf(stderr, "Child can't talk to strangers.\n"); exit(1); printf("Hello, I am child (pid:%d)\n", (int) rc); sleep(1);
} else if (rc == 2) {
} else if (rc > 0) {
int wc = wait(NULL); //is child finished?
printf("Please leave my child alone, I am %d (wc:%d) (pid:%d)\n",
getpid(), wc, (int) rc);
Expand Down

0 comments on commit 34b08b2

Please sign in to comment.