Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions