Description
Assignment 1 (Total points: 70)
Basic Linux/Unix Shell
Linux (and other Unix like OSes), have “shells” or programs which present a command line interface to users to type commands in. In this assignment you need to use standard C libraries, including Linux system calls such as fork(),exec() family system calls and wait() family of system calls.
There are two kinds of commands – “internal” and “external”. Internal commands are those which are interpreted by the shell program itself, without requiring a different program to handle the expected operations (of the said command). Examples of internal commands are like ‘cd’, ‘pwd’, ‘exit’ etc. External commands on the other hand relate to commands which are not handled directly by the shell program but by an external program. Common examples include ‘ls’, ‘cat’, ‘grep’ etc. In this assignment, you have two tasks:
For each of these commands, you need not handle all the command line options. Two options per command is sufficient. You need to document which two options you are handling and need to demonstrate correct functioning of the command with respect to (atleast) your chosen options. You also need to handle corner cases such as invalid options (graceful degradation).
2. The second task would be the achieve the above functionality of the shell using pthread create() (instead of fork()) and system() (instead of
1
execl() family of functions). The thread based execution would be performed if the command is followed by the characters, “&t”. The rest of the functionalities should remain the same. Note: you only need one set of external command programs which could be used with either versions of the shell, be it the that uses fork()/execl() or the one that uses pthread create()/system().
What To Submit
• The C program sources.
• Makefile to compile the source and generate the running binary for the shell.
• Write-up describing the system, the options the shell commands can take, the errors you handled and the assumptions you made. Also provide test cases to test the functioning of the shell.
Grading Rubric
• Successful compilation using Makefile – 5 points.
• Use of system calls like – fork(), execl() family of system calls, wait() family of system calls to handle external commands – 10 points.
• Use of API function calls – system() and POSIX Pthread family of functions (pthread create()) to handle external commands – 10 points. • Correct handling of commands (two options per command, as described earlier) – 20 points.
• Successfully handling atleast two corner cases for each of the commands – 20 points (List the bugs/errors/attacks that you defend against). • Description of the systems, commands to execute and test the program and the assumptions that you made – 5 points.
Late Submission Policy
2
Reviews
There are no reviews yet.