Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.91 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4.  
  5. #define SLEEP sleep(50);
  6.  
  7. // P0
  8. int main()
  9. {
  10.     printf("P0 PID: %d\n", getpid());
  11.     // P3
  12.     if (fork() == 0)
  13.     {
  14.         printf("P3 PID: %d, PPID: %d\n", getpid(), getppid());
  15.         // P9
  16.         if (fork() == 0)
  17.         {
  18.             printf("P9 PID: %d, PPID: %d\n", getpid(), getppid());
  19.             // P10
  20.             if (fork() == 0)
  21.             {
  22.                 printf("P10 PID: %d, PPID: %d\n", getpid(), getppid());
  23.                 execlp("/root/sprawko/help","/root/sprawko/help",(char *)NULL);
  24.                 SLEEP;
  25.                 return 0;
  26.             }
  27.             SLEEP;
  28.             return 0;
  29.         }
  30.         // P8
  31.         if (fork() == 0)
  32.         {
  33.             printf("P8 PID: %d, PPID: %d\n", getpid(), getppid());
  34.             SLEEP;
  35.             return 0;
  36.         }
  37.         SLEEP;
  38.         return 0;
  39.     }
  40.     // P2
  41.     if (fork() == 0)
  42.     {
  43.         printf("P2 PID: %d, PPID: %d\n", getpid(), getppid());
  44.         // P7
  45.         if (fork() == 0)
  46.         {
  47.             printf("P7 PID: %d, PPID: %d\n", getpid(), getppid());
  48.             SLEEP;
  49.             return 0;
  50.         }
  51.         SLEEP;
  52.         return 0;
  53.     }
  54.     // P1
  55.     if (fork() == 0)
  56.     {
  57.         printf("P1 PID: %d, PPID: %d\n", getpid(), getppid());
  58.         // P6
  59.         if (fork() == 0)
  60.         {
  61.             printf("P6 PID: %d, PPID: %d\n", getpid(), getppid());
  62.             SLEEP;
  63.             return 0;
  64.         }
  65.         // P5
  66.         if (fork() == 0)
  67.         {
  68.             printf("P5 PID: %d, PPID: %d\n", getpid(), getppid());
  69.             SLEEP;
  70.             return 0;
  71.         }
  72.         // P4
  73.         if (fork() == 0)
  74.         {
  75.             printf("P4 PID: %d, PPID: %d\n", getpid(), getppid());
  76.             SLEEP;
  77.             return 0;
  78.         }
  79.         SLEEP;
  80.         return 0;
  81.     }
  82.     SLEEP;
  83.     return 0;
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement