Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CS371 Operating Systems Programming Assignment 1: Shell Implementation Purpose There are several goals for this assignment. First, you will get a chance to familiarize yourself

image text in transcribed
image text in transcribed
CS371 Operating Systems Programming Assignment 1: Shell Implementation Purpose There are several goals for this assignment. First, you will get a chance to familiarize yourself with the C/C++ programming language. Second, you will learn how to use some of the 1O facilities and library functions provided by UNIX and C/C++. Third, you develop some experience with the process creation and program starting facilities in UNIX. Fourth, you'll get some experience making your program robust, i.e., resistant to crashing Your assignment is to write a shell: a program that starts up other programs. Your shell, called Cs371sh will read input lines from standard input, parse them into a command name and arguments, and then start a new process running that command. When you start your shell, it will provide a prompt and then wait for a command line of the form: foobar -1 this and that this , "and", and This starts a program stored in a file called-foobar" with four arguments: "that" -l", UNIX/Linux Manual Pages You should become familiar with the UNIX manuals and the online "man" facility. This will be a great help in working on these assignments. For example, if you wanted to know how the fork (create process) system call works, you would type: man 2 fork The UNIX manual is organized into many sections. You will be mainly interested in the first three sections. Section 1 is for commands, like 1s, gec, or cat. Section 2 is for UNIX system calls (calls directly to the UNIX kernel), such as fork, open, or read. You will typically not use Section 2. The UNIX library routines are in Section 3. These are calls such as atof, or strcpy. More details about the online manual will be given in Discussion Sections. Program Details Your shell will loop (until end-of-file) waiting for a line from standard input. Each line has a command and zero or more arguments, and is of the form: and argi .argk Each of these items is separated by one or more blank characters (spaces or tabs). There is one command per input line. Your shell will fork a child process and then overlay itself (exec) the command in the file named by "cmd". The shell parent process will default to waiting for the child process. Optionally, at the end of any command input, can be a "&" character, which means that the parent process does not wait for the child process to complete before prompting for the next command The command line is processed by the shell into a list of character strings, one for each argument (including the command name). These arguments are passed as parameters to the exec command

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

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions

Question

=+a. List the federal taxes withheld from most employee paychecks.

Answered: 1 week ago