Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <stdio.h>
- // 0 -> 1,2
- // 2-> 3
- int main()
- {
- int n1 = fork();
- int n2 = fork();
- if (n1 > 0 && n2 > 0) {
- printf("parent\n");
- while ((wpid = wait(&status)) > 0);
- }
- else if (n1 == 0 && n2 > 0)
- {
- printf("First child\n");
- exit(0);
- }
- else if (n1 > 0 && n2 == 0)
- {
- printf("Second child\n");
- exit(0);
- }
- else {
- printf("third child\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement