#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
  int v = 42;
  pid_t pid;

  printf("Current PID = %d\n", (int)getpid());
  if ((pid = fork()) < 0) {
    perror("fork");
    exit(1);
  } else if (pid == 0) {
    printf("child %d of parent %d\n", (int)getpid(), (int)getppid());
    v++;
    printf("v child = %d\n", v);
  } else {
    printf("v parent = %d\n", v);
    sleep(10); 
  } 
  exit(0);
}
