title: Issue with fork and wait system call
body: <p>I have written a basic c++ program in unix with fork() and wait() system call. I am only creating one child. I have used two pipes. So After fork operation with first pipe i am writing from child to parent and as after parent receives the data, parent is writing back to child in second pipe. after that in parent side I am using wait(0) system call. but still my parent process dies before child process?</p>
  
  <p>structure is something like this:</p>
  
  <pre><code> main()
   char buff[] = "Parent process kills";
   char cuff[] = "before Child process";
   int fd1[2];
   int fd2[2];
   pipe(fd1);
   pipe(fd2);
   if((pid = fork()) == 0)
   {
     close(fd1[0]);
     close(fd2[1]);
     write(fd1[1],buff,strlen(buff)+1);
     read(fd2[0],cuff,sizeof(cuff));
  
   }
   else
   {
      close(fd1[1]);
      close(fd2[0]);
  
      read(fd1[0],buff,sizeof(buff));
      write(fd2[1],cuff,strlen(cuff)+1);
      wait((int *) 0);
    }
  
    close(fd1);
    close(fd2);
  
    }'
  </code></pre>
  
  <p>Even though wait() is used but still parent process dies before child. 
  Thanks in adavance.</p>