Advertisement
bcolan

OTAC;SIN;UNUK

Feb 17th, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. #include<time.h>
  4. #include<stdlib.h>
  5. #include<unistd.h>
  6. #include<sys/shm.h>
  7. #include<signal.h>
  8. #include<sys/ipc.h>
  9. #include<sys/wait.h>
  10. #include<sys/types.h>
  11. #include<unistd.h>
  12. #include<pthread.h>
  13.  
  14. using namespace std;
  15. void otac(int i)
  16. {
  17.     printf("ja sam otac \n");
  18. }
  19.  
  20. void sin(int i)
  21. {
  22.    
  23.     printf("ja sam sin \n");
  24.    
  25. }
  26.  
  27. void unuk(int i)
  28. {
  29.     printf("ja sam unuk \n");
  30.    
  31. }
  32.  
  33. int main()
  34. {
  35.     int i;
  36.     switch (fork())
  37.     {
  38.         case -1: cout<<"greska tijeko stvaranja"<<endl;
  39.             exit(0);
  40.        
  41.         case 0:
  42.                 otac(i);
  43.                 switch(fork())
  44.                 {
  45.                     case -1: cout<<"greska!"<<endl;
  46.                    
  47.                     case 0: sin(i);
  48.                    
  49.                     switch(fork())
  50.                     {
  51.                     case 0: unuk(i);
  52.                     case -1: break;
  53.                     exit(0);
  54.                     }
  55.                     exit(0);
  56.                     default: break;
  57.                    
  58.                 }
  59.                
  60.                 exit(0);
  61.         default:break;     
  62.     }
  63. wait(NULL);
  64. sleep(6);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement