#include 
#include 
#include 
#include 
#include 
#include 

int main(int argc, char *argv[]) {
   
   pid_t chpid;
   int fd, variable, status;
   char ch;
   
   variable = 9;
   fd = open("test.file", O_RDONLY);
   chpid = fork();
   if (chpid != 0) {
      wait(&status);
   }
   else {
      /* Executed only by the child */
      variable = 42;
      close(fd);
      printf("The child has changed the variable to: %d\n", variable);
      printf("The child has also closed the file.\n");
      return(0);
   }
   printf("The variable is now: %d\n", variable);
   if (read(fd, &ch, 1) < 0) {
      perror("READ failed");
      return(1);
   }
   printf("Read from the file: %s\n", &ch);
   return(0);
}