Try Firefox!

Lab 8: Signals


Lab setup
  1. Create a directory lab08 for this lab
  2. Copy this compressed archive file to the above directory:
                  ~wcbrown/courses/IC221/labs/L08/lab08.tar.gz
    	    
  3. Unzip and untar the archive.

Questions
Create a file ans.txt (with your name/alpha at the top!), copy and paste the questions below into it, and add the answers:
1. Read the UNIX man page in Section 3HEAD for the signal header 
   file to answer these questions:

   a. What number corresponds to the SIGKILL signal?

   b. If the disposition for a signal is SIG_DFL with a default 
      action of Core, what happens?

2. Read the UNIX man page in Section 1 for the kill shell utility 
   program to answer these questions:

   a. What is the full path name for this utility program?

   b. Show the shell command you would give to determine all of the 
      signals that are supported on the systems in MI302/MI316.

   c. Write three different ways to send the SIGKILL signal to process 
      id 2010 from the shell.

3. Read the UNIX man page in Section 2 for the kill system call to 
   answer these questions:

   a. What header files must be #include'd to use this system call?

   b. Give 3 reasons why a call to kill() might fail.

4. Make sure you have two shell windows open. The tar archive contains 
   an executable program named banner. Run this program in one of your 
   shell windows. Note: You need to run it as ./banner.

   a. Try and terminate it by entering ^C. What is printed? Explain
      what happened.

   b. Try to suspend it by entering ^Z. What is printed? Explain what 
      happened.

5. In the other shell window:

   a. Determine the process id of the banner program.

   b. Use the kill shell utility program to send it the SIGTSTP
      signal. What keyboard sequence causes the shell to send a
      SIGTSTP signal?

   c. Use the kill shell utility program to send it the SIGTERM
      signal. What is printed? Explain what happened.

   d. Use the kill shell utility program to send it the SIGSEGV
      signal. What is printed? Explain what happened.

   e. What is another signal that you could have sent to terminate the
      running banner program? Explain why this terminates the process.

6. What's the full path to the banner program you get by entering
   banner (not ./banner) at the command prompt? What does that banner
   program do?

	
Programs to write and test
  1. Write a program named hello.c. The program prints its process id, then sits in an infinite loop ( use pause() ) catching these signals and printing a message for each one: SIGCHLD SIGTERM SIGTSTP SIGINT. Test it using the kill shell utility program.

  2. Write a program named killit.c which will take a PID from the command line, then send that process the following signals, in this order: SIGCHLD SIGTERM SIGTSTP SIGINT SIGUSR1. After each one of these signals is sent, make the killit process sleep for one second.

  3. Test killit by having it send signals to hello.

  4. Test killit by having it send signals to banner.

Submission instructions
Follow the general submission instructions. Submit the lab08 directory, which must contain at least the following four files: ans.txt, hello.c, killit.c, and Makefile. The Makefile should compile and link both of your programs. If you save the following into a file Makefile
def: thello tkillit

thello:
 → gcc -o hello hello.c

tkillit:
 → gcc -o killit killit.c
	
... where the "" means a tab character, then the command make should compile both hello and killit.


Christopher W Brown
Last modified: Wed Mar 4 13:19:37 EST 2009