Signals

  1. Signal 1 Indicate the trueness of the following statements by marking them "True" or "False". Briefly justify your answers.
    1. A system call or a library routine using global variable (e.g. errno in C programs) is not signal-safe.
    2. C-library calls "printf" and "scanf" are signal-safe.
    3. Shell command "kill pid" always terminates the designated process.
    4. A "blocked" signal is lost at arrival, i.e. not buffered for later delivery.
  2. Signal 2 A process can be in many different states, e.g. running, waiting for an OS service, ready to run, terminating. For each state of a process, list whether a signal should be queued for later delivery, delivered to the process or ignored by OS. Identify your assumptions.
  3. Signal 3 Consider a C function foo to be called from a signal handler. Identify possible problems if "foo" uses a static local variable or a global variable without synchronization.
  4. Signal 4 Study the program illustrating installation of signal handlers, raise() and signal blocking. Predict its output.
  5. Signal 5 Study the program illustrating signals generated by arithmetic/memory-management errors. Predict its output for each option. Which instruction in main() is executed after return from signal handler?
  6. Signal 6 Consider the process chain program (Program 2.12, pp. 69, Robbins/Robbins). Which process will get an interactive attention signal (SIGINT) if user types in a cntl-c on keyboard? (Hint: Install a handler for SIGINT in the program. The handler should print out the pid for the process receiving the signal. Test the new program a few times to note the process receiving the signal.)

    How can one insure that a specific process (e.g. first process) gets it?

    Consider the problem of "orphan" processes left behind by the program particularly for last part of Exercise 2.12. How can one add kill() call to terminate all processes in chain before the first process exits.

  7. Signal 7 Study the program illustrating difference between reentrant and non-reentrant functions. Predict its output. What makes a function non-reentrant?