Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <stdio.h>
- #include <unistd.h>
- #define SLEEP sleep(50);
- // P0
- int main()
- {
- printf("P0 PID: %d\n", getpid());
- // P3
- if (fork() == 0)
- {
- printf("P3 PID: %d, PPID: %d\n", getpid(), getppid());
- // P9
- if (fork() == 0)
- {
- printf("P9 PID: %d, PPID: %d\n", getpid(), getppid());
- // P10
- if (fork() == 0)
- {
- printf("P10 PID: %d, PPID: %d\n", getpid(), getppid());
- execlp("/root/sprawko/help","/root/sprawko/help",(char *)NULL);
- SLEEP;
- return 0;
- }
- SLEEP;
- return 0;
- }
- // P8
- if (fork() == 0)
- {
- printf("P8 PID: %d, PPID: %d\n", getpid(), getppid());
- SLEEP;
- return 0;
- }
- SLEEP;
- return 0;
- }
- // P2
- if (fork() == 0)
- {
- printf("P2 PID: %d, PPID: %d\n", getpid(), getppid());
- // P7
- if (fork() == 0)
- {
- printf("P7 PID: %d, PPID: %d\n", getpid(), getppid());
- SLEEP;
- return 0;
- }
- SLEEP;
- return 0;
- }
- // P1
- if (fork() == 0)
- {
- printf("P1 PID: %d, PPID: %d\n", getpid(), getppid());
- // P6
- if (fork() == 0)
- {
- printf("P6 PID: %d, PPID: %d\n", getpid(), getppid());
- SLEEP;
- return 0;
- }
- // P5
- if (fork() == 0)
- {
- printf("P5 PID: %d, PPID: %d\n", getpid(), getppid());
- SLEEP;
- return 0;
- }
- // P4
- if (fork() == 0)
- {
- printf("P4 PID: %d, PPID: %d\n", getpid(), getppid());
- SLEEP;
- return 0;
- }
- SLEEP;
- return 0;
- }
- SLEEP;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement