In this assignment, you will use the standard UNIX-style system call interface to create and manage processes.
To submit your work, put your source and text files in a directory and use the turnin command on the eniac cluster. Submit only your source and text files; do not include any compiled executables in your submission. To submit your work, use the command turnin -c cse380 -p hw1 foo/* , where foo/ is the directory containing your work.
Note: The submission system is still being set up; please don't try to submit your work until Wednesday (the 12th).
Using only system calls, write a short C program quickshell that runs other programs, much as the standard Unix shell does but more impatiently. Each line of standard input to your quickshell should contain the name of a program file to execute. Loop to read each input line (until EOF) and run the program file if it exists, waiting for each child process to exit before starting the next. If the child process finishes within 10 seconds, print the message "Wow, that was fast!" on standard output. If a child takes more than 10 seconds, print the message "This is taking much too long!" on standard output. If it then finishes before 15 seconds, print the message "What took so long?" on standard output. If the process is still running after 15 secons, print the message "I've had enough of this!" on standard output and kill the process by sending it a signal. All timer functions should be implemented entirely in the quickshell program.
Each input line to quickshell can be assumed to contain the full path name of a program file to execute (one per line, separated by newline characters). There is no need to parse or process command line arguments or do extensive string processing on the input, although you may need to eliminate the trailing newline character before calling the exec function. You may assume that the standard input is an interactive terminal, and you may limit input lines to some (reasonable) maximum length. (Document any other assumptions you make).
Important: You may use only UNIX system calls (those documented in section 2 of the UNIX man pages, plus any of execl(), waitpid(), sleep(), signal(), kill(), exit() and select() (which are not strictly system calls on some systems)) to implement this program; you may not use any standard library functions (higher-level functions which are documented in section 3 of the manual, such as printf(), etc).
All potential errors, especially those indicated by system call return values, should be handled robustly. Make especially sure to sensibly handle the case where the called program file doesn't exist. Use good coding practices (including appropriate comments, indentation, functional decomposition, etc).
Test and run your program on the eniac Linux cluster.
Hint: Install a signal handler for an alarm signal and schedule an alarm in the parent for 10 seconds after you fork. Test your program by running interactive applications (e.g., cat) that might run for more than 10 seconds. Don't forget to cancel the alarm if the child terminates before 15 seconds and to reset the timer each time you loop to run a new child process.
Give a numbered listing of your quickshell source code and write a detailed (English text) description (in your own words) of the program's operation. It should be aimed at a reader familiar with the C language but not with the UNIX system call interface or process management. Pay particular attention to which processes are running when, and when your program is and isn't blocked.
Your description should be one to three paragraphs in length.
Important: Your description should be submitted in PLAIN ASCII format. No Word files or other proprietary document formats will be graded.
11 September 2007;