Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment Objectives: Demonstrate a basic knowledge of working with processes Identify the parent and child processes in code Use processes to implement a basic shell

Assignment Objectives:

Demonstrate a basic knowledge of working with processes

Identify the parent and child processes in code

Use processes to implement a basic shell

Assignment Details:

In this assignment you will be implementing your own shell program (like bash, sh, csh, zsh, etc). Your shell program will be much simpler than any of those existing shells but the basic concept is the same. This assignment is composed of three distinct parts as described below.

Part 1:

Implement a c shell program that prints a welcome message ("Welcome to the most basic shell program ever!", etc) in the main method. The main method should also start a loop that continually prompts the user to enter a command. The prompt should include the current working directory and any other information you want (machine name, user name, etc).

Part 2:

Read the user input and parse the entered command. You do not need to handle advanced features like quoting or escaping characters. Your program should correctly determine which commands are "built-in" to the shell and all other commands should be treated as external commands.

Part 3:

Implement built-in commands for:

cd - changes the current working directory

quit - quits the program

These commands should be run from the main process. If you try to run them from a child process they will likely not work as expected.

Part 4:

For all commands that are not built-in commands use fork and execvp to run the external command. The parent process should wait for the child to finish and then restart the loop. The child process should execute the command.

Example Pseudocode:

Main: printWelcomeMessage Loop: DisplayPrompt command = ReadAndParseInput if command is builtin: call command builtin function else fork parent: wait child: execvp 

Additional Hints and Tips:

You may find the following functions helpful as you implement this program. chdir, execvp, fork, getcwd, getline, strtok, wait, waitpid

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

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions