fork()
, exec()
, and wait()
NOTE: This assignment, like the other projects in this class, is due at a particular time, listed above. This means that if you are even a minute late, you lose 20%. If you are worried about potentially being late, turn in your project ahead of time. Do this by submitting it electronically before it is due and giving the hard copy to me during office hours or by sliding it under my office door before it is due. Do not send assignments to my personal email address. Do not leave hard copies in my departmental mail box or attempt to give them to departmental staff (who cannot and will not accept them).
As discussed in class, one way to build an application is to use existing applications that each do a part of the job you want your new application to do, then tie them together and add whatever additional functionality is needed to make the whole system work. Take, for instance, an Integrated Development Environment (IDE), as we discussed in class. The main components of an IDE are an editor, a compiler, and a debugger (although other components may be present in some IDEs as well). Rather than writing a new editor, a new compiler, and a new debugger to create an IDE, one could use existing editors, compilers, and debuggers as components of an IDE.
In this assignment, you will take the first step toward the development of an IDE that you could use for projects written in C or C++. This is only the first step, since you have not yet learned in this class about mechanisms for passing the input and output of processes to one another (although you will!), you have not yet learned in this class about mechanisms for reading directory entries (although you will!), and you are not assigned the job of creating a nice GUI front end for your IDE. Still, it will let you gain experience with the basic mechanisms for using other applications to accomplish goals for your new application.
You are to create a program called MyDE
. When run,
MyDE
will present the user with a simple main menu of options:
If the user chooses any of the first three odd-numbered options from the
main menu (1, 3, or 5), MyDE
will present the user with an
appropriate prompt and wait for the user to enter a string. You do not
need to have MyDE
do any sanity check on the string (e.g., to
determine whether the file name given is a valid file name) but you should
not allow for buffer overflows in your code.
If the user chooses the last of the odd options (7), MyDE
will present the user with a configuration submenu, as follows:
Regardless of the option chosen from the configuration submenu,
MyDE
will present the user with an appropriate prompt and wait
for the user to enter a string. You do not need to have MyDE
do any sanity check on the string (e.g., to determine whether the name
entered for the editor corresponds to an actual editor on the system) but
you should not allow for buffer overflows in your code. Once a value has
been entered for a preferred editor, compiler, or debugger using this
submenu, MyDE
will continue to use that value (rather than the
value given in the user's environment or the MyDE
default
value) until the user selects this submenu again and enters a different
value.
If the user chooses any of the even-numbered options from the main menu
(2, 4, or 6), MyDE
will make use of an existing external
application on the system to carry out the request. When MyDE
starts up the external application, MyDE
should provide it
with appropriate information, such as the name of the file to edit and/or
the name of the executable to create.
To determine which editor to use, MyDE
will use the value
entered by the user in the configuration submenu. If the user has not set
a value for the editor using the configuration submenu, MyDE
will examine the environment variable VISUAL
and use the value
found there. If the environment variable VISUAL
is not set or
is set to no value, MyDE
will default to using
gvim
as the editor.
To determine which compiler to use, MyDE
will use the value
entered by the user in the configuration submenu. If the user has not set
a value for the compiler using the configuration submenu, MyDE
will examine the environment variable COMPILER
and use the
value found there. If the environment variable COMPILER
is
not set or is set to no value, MyDE
will default to using
gcc
as the compiler.
To determine which debugger to use, MyDE
will use the value
entered by the user in the configuration submenu. If the user has not set
a value for the debugger using the configuration submenu, MyDE
will examine the environment variable DEBUGGER
and use the
value found there. If the environment variable DEBUGGER
is
not set or is set to no value, MyDE
will default to using
ddd
as the debugger.
When MyDE
uses an external application, it should behave
differently depending on whether the external application provides its own
GUI or uses the terminal in which MyDE
is running. If the
external application provides its own GUI, MyDE
should return
to the main menu immediately after launching the application. If, on the
other hand, the external application uses the terminal in which
MyDE
is running, MyDE
should wait until the
external application exists to return to the main menu. (You should give
MyDE
information about at least one GUI editor and at least
one terminal editor as well as information about at least one GUI debugger
and at least one terminal debugger. If the user or environment variable
specifies an editor or debugger that MyDE
doesn't know about,
MyDE
should query the user as to whether the editor or
debugger provides its own GUI.)
You will turn in both a hard copy and an electronic copy of your assignment. Please follow the instructions on how to send electronic copies. Do not send them to my email address.
Both the hard copy and the electronic copy will contain a write-up plus
the source code for MyDE
. The electronic copy will also
contain the executable of MyDE
. The electronic copy of your
write-up should not be in a proprietary format (such as MS Word); it should
be either in plain ASCII text or in a portable format (such as Postscript
or PDF). Your source code for each MyDE
should be in a single
file called MyDE.c
(for C code) or MyDE.cxx
(for
C++ code) and your executable code should be called MyDE
.
Your source code should be well structured and well commented. It should conform to good coding standards (e.g., no memory leaks, extraneous variables, type mismatches, or unused code).
Your write-up will include 1/2 to 1 page (roughly 80 characters per line, 50 lines per page) explaining the data structures and algorithms used in your code. This page limitation does not include figures used in your explanations, which are encouraged and may take up any amount of space. (The explanations do not remove the requirement that your code be well commented.)
You may write your program from scratch or may start from programs for which the source code is freely available on the web or through other sources (such as friends or student organizations). If you do not start from scratch, you must give a complete and accurate accounting of where all of your code came from and indicate which parts are original or changed, and which you got from which other source. Failure to give credit where credit is due is academic fraud and will be dealt with accordingly.
As noted in the syllabus, you are required to work on this programming assignment in a group of at least two people. It is your responsibility to find other group members and work with them. The group should turn in only one (1) hard copy and one (1) electronic copy of the assignment. Both the electronic and hard copies should contain the names and student ID numbers of all group members. If your group composition changes during the course of working on this assignment (for example, a group of five splits into a group of two and a separate group of three), this must be clearly indicated in your write-up, including the names and student ID numbers of everyone involved and details of when the change occurred and who accomplished what before and after the change.
Each group member is required to contribute equally to each project, as far as is possible. You must thoroughly document which group members were involved in each part of the project. For example, if you have three functions in your program and one function was written by group member one, the second was written by group member two, and the third was written jointly and equally by group members three and four, both your write-up and the comments in your code must clearly indicate this division of labor.