• provide a very primitive interprocess communication (ipc) facility
  • many signals result when a hardware interrupt is handled by UNIX and converted into a "software interrupt" (signal)
  • originally designed in UNIX so that one process could terminate another process


  • system call that would be better called "send_signal"
  • sends a signal from one process to another
  • kill 9: a sure kill

    Signal Table

  • a table of (say) 32 entries kept for each process
  • the exact number of entries depends on the version of UNIX
  • each entry specifies the action to be taken by the process if it receives that type (number) of signal
  • some control keys are translated by UNIX into signals:
  • suspend: removed from the ready list, i.e., it is not available for the cpu scheduler to schedule until it is `continue'd.

    Kill Utility Program

  • UNIX utility program that uses the kill system call to send a signal (by default SIGINT) to a process
  • The signal can be specified by name or by number
  • see man 1 kill


  • % kill 147 - Sends the default signal (SIGINT) to process 147
  • % kill -KILL 147 - Sends the KILL signal, instead of the default signal, to process 147
  • % kill -9 147 - Sends signal number 9, instead of the default signal, to process 147; this particular command has the same effect as kill -KILL 147
  • % kill -9 -1 => Kills all your processes

    System Calls that Affect the Signal Table
    kill: sends signals
    signal: change the response to a signal, i.e., change the entry in the signal table
    fork(): creates a new copy of the signal table for the new process

    Note: the calls to signal are typically all placed at the beginning of a program

    Example 1:

  • Program says "Ha! Ha!" whenever someone types control-C (which is translated to SIGINT).
  • Source code for signal1.cpp
  • Output for signal1.cpp

    Example 2:

  • Program creates a child process that starts looping, and then terminates it.
  • Source code for signal2.cpp
  • Output for signal2.cpp

    Example 3:

  • Program shows that the child can be set up to ignore a signal from its parent.
  • Source code for signal3.cpp
  • Output for signal3.cpp

    Example 4:

  • This program shows that any of several signals can be usefully be intercepted.
  • Source code for signal4.cpp
  • Output for signal4.cpp

    Example 5:

  • This is a simpler example showing that a process can ignore a signal.
  • Source code for signal5.cpp
  • Output for signal5.cpp

    Example 6:

  • A floating point exception (trap) causes a SIGFPE signal, which can be handled (a little).
  • Source code for signal6.cpp
  • Output for signal6.cpp

    Table of Contents