Advertisement
bcolan

procesispisujebroj

Feb 17th, 2020
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. #include <signal.h>
  6. #include <unistd.h>
  7. #include <sys/shm.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. using namespace std;
  14.  
  15. int variable;
  16.  
  17. int ID;
  18. void *test( void *i){
  19. variable=*((int*)i);
  20. printf( "%d \n", variable);
  21. }
  22.  
  23. int main (){
  24.  
  25. int a=10;
  26. int b=20;
  27. int c=30;
  28.  
  29.  
  30. switch ( fork() ){
  31. case -1:
  32. cout << "Greska prilikom stvaranja procesa!" << endl;
  33. exit(0);
  34. case 0:
  35. test(&a);
  36.  
  37.  
  38. exit(0);
  39. default:
  40. break;
  41. }
  42. wait(NULL);
  43. sleep(5);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement