Advertisement
Guest User

czaro

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