title: waitpid() not waiting for child
body: <p>I wrote a really basic shell and for some reason, when I use fork() and then waitpid() the parent process won't wait for the child.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;string.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sys/syscall.h&gt;
  #include &lt;linux/limits.h&gt;
  #include "LineParser.h"
  #include &lt;termios.h&gt;
  
  #define MAX_STR 2048
  void execute(cmdLine *pCmdLine);
  
  
  int main()
  {
      char isContinuing = 1;
      char path[PATH_MAX];
      char str[MAX_STR];
      char something[MAX_STR+PATH_MAX];
      cmdLine* cmd;
      while(isContinuing)
      {
          getcwd(path, PATH_MAX);
          printf("%s$ ", path);
          fgets(str, MAX_STR, stdin);
          if(!strncmp(str, "quit", strlen("quit")))
          {
              isContinuing = 0;
          }
          else
          {
              cmd = parseCmdLines(str);
              if(cmd-&gt;arguments != '\0')
              {
                  execute(cmd);
              }
          }
      }
  
      freeCmdLines(cmd);
      return 0;
  }
  
  void execute(cmdLine *pCmdLine)
  {
      pid_t id = fork();
  
      if(id == 0)
      {
          printf("I AM CHILD.\n");
          if(!execvp(pCmdLine-&gt;arguments[0], pCmdLine-&gt;arguments))
          {
              perror("execvp failed.\n");
              exit(1);
          }
          exit(0);
      }
      printf("I AM PARENT.\n");
      printf("WAITING FOR CHILD.\n");
      waitpid(id);
      printf("DONE WAITING\n");
  
  }
  </code></pre>
  
  <p>LineParser header file is mine and it is fully working.
  Now, for some reason, only the first command is working as expected,
  let's assume an input "echo hi", the output is:</p>
  
  <pre><code>I AM PARENT.
  WAITING FOR CHILD.
  I AM CHILD.
  DONE WAITING.
  </code></pre>
  
  <p>as expected and then it prints "hi" and the path, waiting for a command again.
  For some reason, when I enter the SAME input "echo hi" the second time, the output is:</p>
  
  <pre><code>I AM PARENT.
  WAITING FOR CHILD.
  DONE WAITING.
  $PATH$ //(WITHOUT WAITING FOR INPUT !!!)
  I AM CHILD.
  hi
  //and here waiting for input//
  </code></pre>
  
  <p>Why does this happen?</p>