CSCI 4630
Spring 2000
Programming assignment 1
Due: Feb. 28, 5:00pm. Turn in your program by mailing the
source code to karl@cs.ecu.edu, with heading
CSCI 4630 program 1, your name
where you write your name, not literally "your name". If you have
an inquiry about the assignment, do not use this subject, since
I will just file it away if you do.
Do not turn in an untested program! Make sure it works.
|
The assignment
Write an extremely simple command interpreter for Unix systems.
The command interpreter should work as follows.
The interpreter should repeatedly print a prompt and
read a command. The command will be the name of a file, either
relative to the current directory or absolute. There will be
no arguments on the command. For example, the command might be
/bin/ls
After reading the command, the interpreter should perform
the command. It should do this by
- forking a child process to perform the command;
- doing an exec in the child process to make the child become the program
that is to be executed;
- doing a wait in the parent process so that the interpreter
does not print the next prompt until the command is finished.
Upon reading the special command exit, the command interpreter
should stop.
To implement this, you will need to use the fork, execv and
wait system calls. You can read about them in their manual pages.
To find out about fork, for example, use command
man fork
Programming language
Write the program in either C or C++. Most of you will be
more familiar with C++. For operating system programming, the
more basic language C is often more appropriate. The only noticeable
differences to you for this program are
- If you use C, you need to use printf for output and scanf for
input. The C++ stream feature (cin, cout, etc.) is not available.
There are manual pages for both printf and scanf. Include header
file stdio.h, not iostream.h, in a C program.
- You compile a C program using gcc, not g++.