Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.40 KB | None | 0 0
  1. #include <cstdio>
  2. #include <sys/types.h>
  3. #include <unistd.h>
  4. using namespace std;
  5.  
  6. int main() {
  7.     puts("initializing");
  8.     int a = 5, *p = &a, pid;
  9.  
  10.     printf("dad pid: %d\n", getpid());
  11.     pid = fork();
  12.     if(!pid) {
  13.         *p = 3;
  14.  
  15.     } else {
  16.         sleep(1);
  17.         printf("dad_a %d\n", a);
  18.     }
  19.  
  20.     printf("a from %d: %d\n",getpid(), a);
  21.     printf("reference %p", p);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement