title: how does execlp() system call work?
body: <pre><code>#include &lt;sys/types.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  
  int main(){
  pid_t pid;
  pid = fork();
  if(pid&lt;0){
     fprintf(stderr, "fork failed");
     return 1;    }
  else if(pid == 0){  
     execlp("bin/ls", "ls", NULL);}
  else{
     wait(NULL);
     printf("child complete\n");
     }
  return 0;
  }
  </code></pre>
  
  <p>Here as far as I could understand, a child process is created and since its pid returned by fork is "0", it enters the block containing execlp and executes it, and then the parent waits till the child exits and then prints "child complete". Please correct me if I'm wrong. But I didnt understand how execlp() works here. Can someone explain this?</p>