title: create a process to execute any command
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;sys/wait.h&gt;
  #include &lt;unist.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define LINE_MAX 255
  #define ARG_MAX  10
  
  #define SH_PROMPT "next&gt; "
  
  int run_command(char *[]);
  int getline(char *);
  void parse_line(char *, char*[]);
  
  int main(void)
  {
      char line[LINE_MAX+1];
      char *argbuf[ARG_MAX+!];
      int temp;
  
      do{
          printf(SH_PROMPT); fflush(stdout);
          if ((temp = getline(line)) != -1){
              parse_line(line, argbuf);
              run_command(argbuf);
          }
      } while (temp != -1);
      return 0;
  }
  
  
  int run_command(char *command[]){
      pid_t child;
      pid_t c;
  
      if ((child = fork()) == 0){
          execvp(command[0], command);
          fprintf(stderr, "Child process could not do execvp.\n");
          exit(1);
      }
      else{
          if(child == (pid_t)(-1)){
              fprintf(stderr, "Fork failed - Use spoon. \n");
              exit(1);
          }
          else {
              c = wait(NULL);
              return 0;
          }
      }
  }
  </code></pre>
  
  <p>I want to write a program which will create a new process and in that child process, it should execute any command. In the meanwhile, When a child process terminates, the parent process should print one line on the standard output stating that the relevant command has completed successfully or not successfully (such as "Command /bin/who has completed successfully"). Once all of its child processes have terminated, the parent process should print "All done, bye-bye!" before it itself terminates. I need help with my code for completion and error-checking. Please help, thank you!</p>