title: fork process always returning > 0 i cannot figure out why?
body: <p>Hello i am creating a simple shell in C, currently i am having an issue with fork as it always seems to return a value &gt; 0 even when i type in some non linux command like &quot;ehshhduh&quot; it will still print out&quot;Chile process complete&quot; instead of returning an Error message could anyone explain to me what i am doing wrong thanks?</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdbool.h&gt; 
  #include &lt;string.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;sys/types.h&gt;
  
  
  char str_tokens[50];
  
  char * get_input() {
      pid_t pid; 
      char *tokens[30][50];
      char input[512];
      char *charp;
      char *burner[20];
    
      int i = 0;
  
  while(true) {
     printf(&quot;&gt;&quot;);
     if(fgets(input, 512, stdin) == 0 || strncmp(input, &quot;exit&quot;, 4) == 0) {    /* reads in input from user no more than 512 chars including null terminator, program terminates if &quot;exit&quot; or CTRL-D is detected*/
       printf(&quot;exitting program&quot;);
         exit(0);
     } 
  
      const char delimiters[9] = {'&amp;', ';', '\n', '|', ' ', '\t', '&gt;', '&lt;',}; 
      charp = strtok(input, delimiters); /* splits the string on delimiters */
      while (charp != NULL) {
        
           strcpy(str_tokens, charp);
          charp = strtok(NULL, delimiters);   // sets the char pointer to null
                                                  //after each split of the string 
                                                  //so the loop eventually terminates */
          } 
         char *args[] = {str_tokens, 0};  
  
      pid = fork();     // fork a child process
      if (pid == -1) { /* error occured */
          fprintf(stderr, &quot;Error occured with Fork&quot;);
          return 1;
      }
       else if (pid &gt; 0) {  /* parent process */
          /* parent will wait for the child process to complete */
          wait(NULL);
          printf(&quot;Child process completed&quot;) ;
      }
      else if(pid == 0){ // (pid == 0)  /* this is the child process */
          execvp(args[0], args);          /* first param the file path, seconf is null terminated array of char pointers*/
          printf(&quot;this is the child process&quot;);
          _exit(EXIT_FAILURE);            /* in the case our exec never returns exit */
      }
     
  
      }
    
     return str_tokens;
  }
  
  
  void run_external(char* commands[50]) {
      commands = get_input();
  }
  
  int main () {
   run_external(get_input());
     return(0);
      
  }
  </code></pre>