title: Child process never executes after fork
body: <p>I have to make a C program that gives to the parent a string, the parent edits it, puts into a pipe, then the child validates it and sends it back. For some reason only the parent executes. I wanted the parent to send the text, then wait for the execution of the child, and read the answer. But the code simply ignores the child completely.</p>
  
  <p>Here's the snippet:</p>
  
  <pre><code>char response[10];
  pid_t pid = fork();
  int p[2];
  pipe(p);
  if(pid!=0)
  {
      char username[255];
       CutString(8,command,username); // a function of mine i verified 
       write(p[1],username,sizeof(username));
       close(p[1]);
       wait(NULL);
       read(p[0],response,8);//the answer is always 8 bytes
       close(p[0]);
  }
  else //never gets here
  {
       char buffer[255];
       size_t bufferIndex=0;
       char ch;
       while (ch != '\0')
       {
           read(p[0],&amp;ch,1);
           buffer[bufferIndex++]=ch;
       }
       close(p[0]);
       f=fopen("config.txt","r");
       write(p[1],SearchInFile(f,buffer),8);
       close(p[1]);
  }
  </code></pre>