Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <unistd.h>
- #include <sys/wait.h>
- #include <stdio.h>
- int main()
- {
- int pid, pid2, pid3;
- pid = fork();
- if( pid == 0 )//potomny 1
- {
- execl( "d1","", NULL );
- sleep(1000000);
- }
- else
- {
- pid2=fork();
- if(pid2==0)
- {//potomny2
- execl( "d2","", NULL );
- sleep(1000000);
- }
- else
- {
- pid3=fork();
- if(pid3==0)//potomny3
- {
- execl( "d3","", NULL );
- sleep(100000);
- }
- else
- {
- waitpid(pid, NULL, 0);
- waitpid(pid2, NULL, 0);
- waitpid(pid3,NULL, 0);
- }
- }
- }
- //printf("%d %d %d", pid, pid2, pid3);
- // waitpid(pid, NULL, 0);
- //waitpid(pid2, NULL, 0);
- // waitpid(pid3,NULL, 0);
- }
- https://www.drivehq.com/folder/p12389137.aspx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement