now that the users command has been parsed into


Now that the user's command has been parsed into an array of char*, we can pass this to the OS to execute the command. To execute the command, use the execvp() function from unistd.h. You will pass your command array to this function which will execute the command. Remember that if this function executes properly, it will terminate the current process; so, it should be executed in a child process. The child process can be created with the fork() function which is also in unistd.h. While the child process is executing the command, the parent process should wait for the child to finish executing. This is done by using the waitpid() function which can be found in sys/wait.h. As you are waiting on the child process, you will want to make this call blocking. You can do this by giving the WUNTRACED option to the waitpid() call which is defined in sys/types.h. Remember that if the execvp() function does not complete successfully, the child process will not end. As this will only happen when an error occurs, this would be a good place to print the error message. This can be done easily by calling the perror(NULL) function. Then be sure to end the child process by calling the exit() function. Once the command is done, you should print your prompt on a new line.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: now that the users command has been parsed into
Reference No:- TGS0221929

Expected delivery within 24 Hours