Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include<stdio.h>
- #include<unistd.h>
- #include<sys/types.h>
- int main()
- {
- char tree[80];
- if(fork() == 0)
- {
- pid_t pid_1 = getpid();
- printf("Proces pid_1 = %d\n", pid_1);
- sprintf(tree, "pstree -cp %d", pid_1);
- if(fork() == 0)
- {
- pid_t pid_2 = getpid();
- printf("Proces pid_2 = %d\n", pid_2);
- if(fork() == 0)
- {
- pid_t pid_3 = getpid();
- printf("Proces pid_3 = %d\n", pid_3);
- sleep(100);
- _exit(0);
- }
- if(fork() == 0)
- {
- pid_t pid_4 = getpid();
- printf("Proces pid_4 = %d\n", pid_4);
- sleep(100);
- _exit(0);
- }
- if(fork() == 0)
- {
- pid_t pid_5 = getpid();
- printf("Proces pid_5 = %d\n", pid_5);
- sleep(100);
- _exit(0);
- }
- sleep(100);
- _exit(0);
- }
- if(fork() == 0)
- {
- pid_t pid_6 = getpid();
- printf("Proces pid_6 = %d\n", pid_6);
- if(fork() == 0)
- {
- pid_t pid_6 = getpid();
- printf("Proces pid_6 = %d\n", pid_6);
- sleep(100);
- _exit(0);
- }
- if(fork() == 0)
- {
- pid_t pid_7 = getpid();
- printf("Proces pid_7 = %d\n", pid_7);
- sleep(100);
- _exit(0);
- }
- if(fork() == 0)
- {
- pid_t pid_8 = getpid();
- printf("Proces pid_8 = %d\n", pid_8);
- sleep(100);
- _exit(0);
- }
- sleep(100);
- _exit(0);
- }
- system(tree);
- sleep(100);
- _exit(0);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement