title: run background process linux simple shell. C++
body: <p>I'm creating a simple shell in linux and I'm having trouble getting a command to run in the background. </p>
  
  <p>here is my code so far:</p>
  
  <pre><code>create command,argv and check if it is to be ran in the background &amp;
  enter this code:
  
  if(strcmp(command,"cd")==0)
  {        
    chdir(argv[1]);
  
  }
  else if(strcmp(command,"clr") == 0)
  {
    if ((pid = fork()) == 0) 
    {        
       execvp("clear",argv);
    }
    wait(&amp;status);
  }
  else
  {      
     if ((pid = fork()) == 0)
  {        
    execvp( prog, argv );        
  }
    wait(&amp;status);
  
  }
  </code></pre>
  
  <p>command and argv are what I get from the user. </p>
  
  <p>I need to run a command in the background if '&amp;' is the last part of the command. I have already checked for that with a boolean var of bg. but I'm having trouble with the WAITPID() function im not sure where it goes.</p>