title: How to run 2 processes at the same time in C?
body: <p>I'm creating a program in C like terminal shell in which is my exercise in class. That program allow to run multiple processes at the same time if you add '&amp;' at end of sentence. ( example : $ gedit &amp; ); However, my code just run father process when child process exit. </p>
  
  <pre><code>#include  &lt;stdio.h&gt;
  #include  &lt;sys/types.h&gt;
  #include &lt;string.h&gt;
  
  void  parse(char *line, char **argv)
  {
       while (*line != '\0') {       /* if not the end of line ....... */ 
            while (*line == ' ' || *line == '\t' || *line == '\n')
                *line++ = '\0';     /* replace white spaces with 0    */
  
            *argv++ = line;          /* save the argument position     */
            while (*line != '\0' &amp;&amp; *line != ' ' &amp;&amp; 
                   *line != '\t' &amp;&amp; *line != '\n') 
                 line++;             /* skip the argument until ...    */
       }
       *argv = '\0';                 /* mark the end of argument list  */
  }
  
  
  void  execute(char **argv)
  {
       pid_t  pid;
       int    status;
  
       if ((pid = fork()) &lt; 0) {     /* fork a child process           */
            printf("*** ERROR: forking child process failed\n");
            exit(1);
       }
       else if (pid == 0) {          /* for the child process:         */
            if (execvp(*argv, argv) &lt; 0) {     /* execute the command  */
                 printf("*** ERROR: exec failed\n");
                 exit(1);
            }
       }
       else {                                  /* for the parent:      */
              wait(NULL);                          /* wait for completion  */
  
       }
  }
  
  void  main(void)
  {
       char  line[1024];             /* the input line                 */
       char  *argv[64];              /* the command line argument      */
  
       while (1) {                   /* repeat until done ....         */
            printf("COMMAND -&gt; ");     /*   display a prompt             */
            gets(line);              /*   read in the command line     */
            printf("\n");
            parse(line, argv);       /*   parse the line               */
            if (strcmp(argv[0], "exit") == 0)  /* is it an "exit"?     */
                 exit(0);            /*   exit if it is                */
            execute(argv);           /* otherwise, execute the command */
       }
  }
  </code></pre>
  
  <p><strong>I want to result like:</strong></p>
  
  <p>Ex: $ gedit &amp;   // program gedit run with pid = 4789</p>
  
  <p>$ emacs // program emacs run with pid = 5123 ppid = 4789</p>