Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter, called

image

image

Project 1: Implementing a Shell 1 Overview In this individual project you will have to design and implement a simple shell command interpreter, called mysh. The basic function of a shell is to accept lines of text as input and execute programs in response. The shell must be able to execute built-in commands in a process different from the one executing mysh. 2 Requirements When first started, your shell should initialize any necessary data structures and then enter a loop of printing a prompt, e.g. "mysh#", reading any commands entered by the user and executing them. 2.1 Simple execution of commands mysh executes a program in the foreground, waits for it to terminate, and then resumes control, e.g. mysh# vi would launch the vi editor, the user can then perform text processing and after the user quits vi, control is returned back to the shell. The user shouldn't have to type in the full path to executables as long as they are within the search path specified the environment by the PATH variable. In your initial implementation mysh should spawn a child process and block wait for the child to terminate. The relevant system calls here are fork(), the wait() and exec() families of calls, and exit(). 2.2 Parsing the command line When parsing the command line, mysh should ignore all whitespace. You might find the isspace and strtok man pages useful. Please keep in mind that your commandline parser should work, but we do not expect it to be particularly fancy. For example, and should not be treated specially by the parser. We'd much rather see you spend a lot of effort on the job control features of your shell. 2.3 Built-in commands Mysh should support the following built-in commands. jobs: Print a list of commands that are currently running or suspended. This list should include an integer, the command line that started the respective program and the status (Running or Suspended) of the program, e.g. mysh# jobs [1] Running [2] Running [3] Suspended [4] Suspended xemacs project1.tex xdvi projectl vi firefox kill %job: Sends a SIGTERM signal to the specified job, e.g. mysh# kill $2 would terminate the xdvi program from the previous example. fg %job: Continue executing the specified command in the foreground, e.g. mysh fg #3 would bring the vi program to the foreground. The shell would then wait for the user to either terminate the vi program or to suspend it using Control-Z. bg %job: Put the specified job in the background, continuing it if it was suspended, e.g. if a user had started the firefox web browser, and suspended it using Control-Z, then mysh# bg $4 should let the browser continue running in the background. pwd: Print the current working directory. cd path: Change the current working directory to specified path. 3 Hints and Tips The man pages are your friends! Manpages of particular interest would be: fork() exit() exec(), execl(), execv(), execle(), execve(), execip(), execvp() wait(), waitpid() kill() isspace(), strtok() This project should be developed on a UNIX OS. You are free to use any flavor of UNIX you want for development. It should contain at least three parts: 1) an introduction to the basic structure of your shell; 2) a list of which features are fully implemented, partially implemented, and not implemented; and 3) a discussion of how you tested your she correctness.

Step by Step Solution

3.52 Rating (169 Votes )

There are 3 Steps involved in it

Step: 1

Answer 1 Introduction The goal of this project is to design and implement a basic shell comm... 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

Cornerstones of Financial Accounting

Authors: Jay Rich, Jeff Jones

4th edition

978-1337690881, 9781337669450, 1337690880, 1337690899, 1337669458, 978-1337690898

Students also viewed these Operating System questions