Lab - III


8 August 2019

In this lab, you will explore the use of signals for interprocess communication.

kill -l command lists all the signals.

Problems:

  1. Write a simple signal handler that prints, "You cannot kill me with Signal signo" where signo is the signal that is being handled.
    Send the correct signal to the process by finding its PID and using the kill command.
  2. For the problem above, experiment with different signals, esp., SIGHUP, SIGINT, SIGQUIT, SIGFPE, SIGSEGV, SIGCHLD and SIGKILL. In each case, see what happens when you send the signal once, and more than once. Explain their behaviours (read the man page of signal).
  3. Write a program that sets up a suitable signal handler and then goes to sleep for 20 or 30 seconds. You can use the sleep() function. Do signals get delivered during sleep? How do the different signals behave?
  4. Trace any of your processes all the way back to init process with PID = 1. Find out about the processes along the way.
  5. Write a program that forks a child processes and waits for it to complete (wait() or waitpid()). While it is waiting, what happens if you send it a signal? Try different signals such as SIGINT, SIGFPE, SIGCHLD, SIGKILL.

Write your observations in a text, Word or LaTeX document during the lab. At the end, create a gzipped tar file of all your source codes and observations document. Email it to chakcs@uohyd.ernet.in with the subject as OS Lab-03.