Question: PLEASE WRITE IN C Phase 2: In Phase 2, we will develop a simple command interpreter (shell) for Linux It should be structured as a

 PLEASE WRITE IN C Phase 2: In Phase 2, we will

PLEASE WRITE IN C

Phase 2: In Phase 2, we will develop a simple command interpreter (shell) for Linux It should be structured as a loop, like: 1. Display a prompt, made up of your first name, followed by the string "> " Read a Linux command line from keyboard into some variable like char *str 3. If this line is empty, then exit the program 4. Otherwise, break this line into words by something like char **w words (str); 5. Use the system call fork ) to spawn a new child process, like in Figure 1-19 on the textbook Page 55 a. Child process calls execvp (w[0], w) to execute the command entered from keyboard b. Parent process employs waitpid) to wait for the child to complete 6. When child terminates, parent resumes, frees all dynamically allocated memory created by words () , and jumps to Step 1 An Example Run: Here's an example run (shell output in red, user input in blue, child process output in black) Rajiv> date Mon Jan 28 15:59:01 CST 2019 Rajiv> ps -a PID TTY 60670 ttys000 60674 ttys000 60696 ttys000 Rajiv> 1s -l /Users total 0 drwxr-xr-x+ 11 Guest TIME CMD 0:00.08 login -pf rajiv 0:00.03 -bash 0:00.00 ps-a guest 374 Dec 9 2015 Guest rwxrwt 7 root wheel 238 Oct 17 2015 Shared drwxr-xr-x+ 38 rajiv staff 1292 May 262018 rajiv Rajiv>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!