The shell must wait that a new process terminates before ask a new command to the user. Done.

Now i want my shell to support extern commands without user interaction (background) when a command is given with a "&" in the end (assuming & is a separate word) the shell won't wait for this to end before ask a new command,

this is my method that runs external commands.

Code:
#include <stdio.h>
#include <string.h> 

int runcommand( char **myargv ){


int pid, status,i;
	  
//	   waitpid(-1, &status, 0); //check for zombies ? 
	/*
	 *new child 
	 */
	if ((pid = fork()) < 0) 
	{
		perror("fork");
		return -1;
	}

	/*
	 * run child
	 */
	if (pid == 0) 
		{
	if (execvp(myargv[0], myargv) < 0 )
	perror("Error");
		}
	else
		/*
		 * Father waits
		 */
		if(pid > 0)
		{
			while (wait(&status) != pid);
			}
	
}
i'm kinda confused here , any help would be apreciated.