Docsity

Operating Systems Shell Project Part 2: Job Control and Signal Handling, Study Guides, Projects, Research of Operating Systems

Toggle sidebar
bg1
COMPSCI 453/552: Operating Systems
Shell Project Part 2 (90 points)
Due Date –On Class Home Page–
1 Introduction
In this part of the shell project, we will be adding job control to your shell. You should also continue
using the Subversion source code control system to manage your project.
2 New features for Dash version 2.x
1. Signal Handling. (20 points) Set up signal handling in your shell. The shell should not
terminate on SIGINT (the interrupt key, usually Ctrl-c) and should not stop on the signal
SIGTSTP (the keyboard stop signal, usually Ctrl-z).
A job running in the background should not be affected by these signals.
A foreground job should respond to these signals. In case of SIGTSTP, the shell should display
a message stating what command got suspended. For example, on typing ctrl-z while the
sleep command is running below:
dash> sleep 100
[2]+ Stopped sleep 100
dash>
If there is no current foreground job, then the shell should just display a new prompt and
ignore any input on the current line.
For ease in testing (and making it easier for me to report bugs), have your shell print out
“Caught Control-c” or “Caught Ctrl-z” when it catches these signals and no foreground job
is running. Extend your jobs command so that it also shows stopped jobs.
2. Recursive Invocation (10 points). How does your shell behave if invoked recursively?
By recursive, we mean running dash from dash. Which invocation catches the signal? How
do you resolve this issue? Note that your implementation should not rely on checking if the
command to run is named “dash” but be more general.
3. Additional job control features. (30 points) Add the built-in commands fg and bg that
allow the last process stopped (with SIGTSTP or Ctrl-z) to be restarted using the SIGCONT
signal (check the man page for signal in section 7, man 7 signal).
By default, the fg and bg commands apply to the last stopped process. However, with an
optional argument the commands can apply to any stopped job or job running in background.
For example, fg 2 brings the second job to the foreground (if there is a job number 2). Note
pf3
pf4

Partial preview of the text

Download Operating Systems Shell Project Part 2: Job Control and Signal Handling and more Study Guides, Projects, Research Operating Systems in PDF only on Docsity!

COMPSCI 453/552: Operating Systems

Shell Project Part 2 (90 points)

Due Date –On Class Home Page–

1 Introduction

In this part of the shell project, we will be adding job control to your shell. You should also continue using the Subversion source code control system to manage your project.

2 New features for Dash version 2.x

  1. Signal Handling. (20 points) Set up signal handling in your shell. The shell should not terminate on SIGINT (the interrupt key, usually Ctrl-c) and should not stop on the signal SIGTSTP (the keyboard stop signal, usually Ctrl-z). A job running in the background should not be affected by these signals. A foreground job should respond to these signals. In case of SIGTSTP, the shell should display a message stating what command got suspended. For example, on typing ctrl-z while the sleep command is running below:

dash> sleep 100 [2]+ Stopped sleep 100 dash>

If there is no current foreground job, then the shell should just display a new prompt and ignore any input on the current line. For ease in testing (and making it easier for me to report bugs), have your shell print out “Caught Control-c” or “Caught Ctrl-z” when it catches these signals and no foreground job is running. Extend your jobs command so that it also shows stopped jobs.

  1. Recursive Invocation (10 points). How does your shell behave if invoked recursively? By recursive, we mean running dash from dash. Which invocation catches the signal? How do you resolve this issue? Note that your implementation should not rely on checking if the command to run is named “dash” but be more general.
  2. Additional job control features. (30 points) Add the built-in commands fg and bg that allow the last process stopped (with SIGTSTP or Ctrl-z) to be restarted using the SIGCONT signal (check the man page for signal in section 7, man 7 signal). By default, the fg and bg commands apply to the last stopped process. However, with an optional argument the commands can apply to any stopped job or job running in background. For example, fg 2 brings the second job to the foreground (if there is a job number 2). Note

that this implies that you can use the command fg to bring any running background job into the foreground.

Here are are some example scenarios. Suppose you have just stopped a foreground process and then back-grounded it, the output of your built-in command jobs would look something like the following (before and after the bg command):

dash> loop [3] Stopped loop dash> jobs [0] Running sleep 101 & [1] Running sleep 103 & [2] Running sleep 105 & [3] Stopped loop dash> bg [3] loop dash> jobs [0] Running sleep 101 & [1] Running sleep 103 & [2] Running sleep 105 & [3] Running loop & dash>

Here the program loop is just the following simplistic infinitely looping/sleeping program:

main(){for(;;){sleep(100);}}

It is better to use this program than the sleep command for this type of testing.

Here is another example:

dash> loop [0] Stopped loop dash> loop [1] Stopped loop dash> jobs [0] Stopped loop [1] Stopped loop dash> bg [1] loop dash> jobs [0] Stopped loop [1] Running loop & dash> bg [0] loop dash> jobs [0] Running loop & [1] Running loop &

your linked list, a copy must be left at the top level of your submitted folder. Failure to follow the above two instructions will cost you 10% of the grade.

Also make sure that there is a README file that contains your name, date, assignment number, design and observations about the assignment.

Make sure that you save the subversion log file as svn.log in your submission directory. Also the submission directory should be a subversion working directory.

Prepare your directory for submission by removing all executables and object files and other clutter. You should only have the source code, README files, Makefiles, test scripts and test files before submitting.

Change to the top level of your project directory and type the following command (on onyx) to submit the assignment.

submit amit cs453 4

or

submit amit cs552 4

This command will pick up all files in the current directory (as well as any subdirectories recursively) and time-stamp them before transferring the combined files to the instructor’s account.