title: strtok and execlp in a mini-shell
body: <p>I'm writing a mini-shell to get more familiar with Unix process management in C. It's reading stuff from commandline and passes these arguments via execlp to the system. </p>
  
  <pre><code># include &lt;stdio.h&gt;
  # include &lt;stdlib.h&gt;
  # include &lt;unistd.h&gt;
  
  #define MAXSIZE 100
  
  char prompt[MAXSIZE];
  
  int main(void)
  {
     pid_t pid;
  
     printf("&gt; ");
  
     // read stuff 
     if (fgets(prompt, MAXSIZE, stdin) == NULL){
        printf("Input validation error!");
        abort();
     }
     // printf("DEBUG: %s" , prompt);
  
     if (strcmp(prompt, "exit")==0) abort();
  
  
     if ((pid=fork())&lt;0){       // copy process
  
        printf("Process error!");
        abort();
     }
  
     if (pid==0){                // exec in son-prcess
  
        char *command=(char*)strtok(prompt, " ");
        execlp(command, command, 0);  // overwrite memory
  
        printf("Error, command not found!");
        abort();
     } else {
  
        waitpid(pid, 0, 0);
      }
  }
  </code></pre>
  
  <p>In fact this would be it, but I don't get any output from <code>execlp()</code>.
  Does anybody know why that is?</p>