shlab - CS 2400 Fall 2010 Lab Assignment L5 Writing Your...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 2400, Fall 2010 Lab Assignment L5: Writing Your Own Unix Shell Introduction The purpose of this assignment is to become more familiar with the concepts of process control and sig- nalling. You’ll do this by writing a simple Unix shell program that supports job control. Logistics You may work in a group of up to two people in solving the problems for this assignment. The only “hand- in” will be electronic. Any clarifications and revisions to the assignment will be posted on the course Moodle page. Hand Out Instructions You will be using your Ubuntu Linux virtual machine to complete this assignment. Alternatively, you can use the CSEL machines (“elra-01”, etc) or your native Linux install. Download the file shlab-handout.tar from the Moodle “assignment” page. Start by copying the file shlab-handout.tar to the protected directory (the lab directory ) in which you plan to do your work. Then do the following: Type the command tar xvf shlab-handout.tar to expand the tarfile. Type the command make to compile and link some test routines. Enter your team member names in the header comment at the top of tsh.c . Looking at the tsh.c ( tiny shell ) file, you will see that it contains a functional skeleton of a simple Unix shell. To help you get started, we have already implemented the less interesting functions. Your assignment is to complete the remaining empty functions listed below. As a sanity check for you, we’ve listed the approximate number of lines of code for each of these functions in our reference solution (which includes lots of comments). 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
eval : Main routine that parses and interprets the command line. [70 lines] builtin cmd : Recognizes and interprets the built-in commands: quit , fg , bg , and jobs . [25 lines] do bgfg : Implements the bg and fg built-in commands. [50 lines] waitfg : Waits for a foreground job to complete. [20 lines] sigchld handler : Catches SIGCHILD signals. 80 lines] sigint handler : Catches SIGINT ( ctrl-c ) signals. [15 lines] sigtstp handler : Catches SIGTSTP ( ctrl-z ) signals. [15 lines] Each time you modify your tsh.c file, type make to recompile it. To run your shell, type tsh to the command line: unix> ./tsh tsh> [type commands to your shell here] General Overview of Unix Shells A shell is an interactive command-line interpreter that runs programs on behalf of the user. A shell repeat- edly prints a prompt, waits for a command line on stdin , and then carries out some action, as directed by the contents of the command line. The command line is a sequence of ASCII text words delimited by whitespace. The first word in the command line is either the name of a built-in command or the pathname of an executable file. The remaining words are command-line arguments. If the first word is a built-in command, the shell immediately executes the command in the current process. Otherwise, the word is assumed to be the pathname of an executable program. In this case, the shell forks a child process, then loads and runs the program in the context of the
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 7

shlab - CS 2400 Fall 2010 Lab Assignment L5 Writing Your...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online