~/man/man1
is to contain a
man page for the executable program. You may leave a
README
file in the project directory if you think that one
is needed, but I neither expect nor require you to do so.
~vickery/CS-701/APUE
. You will find Program 1.8 and
ourhdr.h
in proc/shell2.c
, and
error.c
in lib.sun
.Do the exercise as a sequence of steps. Most of you will have done some or all of Steps 2 and 3 before you got the assignment, so you will have to go back and do Step 1 out of sequence.
Be sure the last line is indented using aOBJS = shell2.o error.o myshell : $(OBJS) $(CC) $(CFLAGS) $(OBJS) $(LDLIBS) -o $@
<tab>
character, not spaces. You should now be able to build the executable
shell2 program by issuing the command, "make".
shell2.c
so that it follows the Coding Guidelines for this
course. You do not have to edit the other two files.
Be sure the program still works!
To do this, you will have to break each command line into a sequence of space-separated tokens using the strtok() standard library function. There is sample code to do this in the Harbison and Steele book listed in the CS-701 Course Description.
It would be very hard to use the execlp() function to handle command line arguments. You would have to have a separate call for each of the different number of number of arguments the user might enter! Instead, look up the execvp() function in the man pages, and use that. You will save each of the pointers returned by strtok() in an array, and pass the array as the second argument to execvp().
Extra Credit: Handle command line arguments in quotes properly.
^C when the program is running causes
the "interrupt
" message to be displayed, a new prompt to
be issued, and the program exits. Fix the program so it continues to
accept command lines instead of exiting.
To do this, you will have to check to see if the global variable
errno
is set to EINTR
(defined in
errno.h
) when the fgets() function returns
NULL
. If so, repeat the fgets() instead of
exiting.
Extra Credit: Make the program contine to accept commands no matter
how many times the user types ^C
.
- Write a man page for the new shell program. It may be very
brief, but it must be in standard man page format, and it must
be installed properly. Consult the man page handout
for this course and/or the
man entry in Section 5 of the on-line man pages for information
on how to mark up the text of your man page.