Skip to content

Latest commit

 

History

History
87 lines (58 loc) · 1.83 KB

SIGNALS.md

File metadata and controls

87 lines (58 loc) · 1.83 KB

signals

Testing spinner behavior during interrupts and termination signals can be done with the following command and cases:

Normal spinning

Everything should spin and stop without problem:

$ ./wait     # And then wait
$ echo $?    # 0

Timing interrupts

There are a few places to try interrupting and testing error codes. These include:

  1. Before the spinner is created
  2. Before the spinner starts
  3. After the spinner starts
  4. After the spinner stops

Outputs will indicate when these points are reached. Interrupt at each of these to verify the cursor returns.

Sending different signals

Different types of interrupt signals can be sent with the following key combos:

  • SIGINT: CTRL-C
  • SIGQUIT: CTRL-\

And a SIGTERM can be generated by killing the process from another window:

$ ./wait
SPIN TEST: preparing test program #42550
...
$ kill 42550

Expected error codes

The error codes for each of these interrupts can be checked with:

$ echo $?
0

Expected values for each of the above interrupts might be:

  • SIGINT: 130
  • SIGQUIT: 131
  • SIGTERM: 143

More information on exit codes can be found here.

Capturing signals from the small program

The small program (which calls spinner) can also capture interrupts and handle interrupts itself:

$ ./wait --signal

Note: SIGQUIT is not captured to allow checks of the unchecked signal case.

Calling the small program from a bigger program

All of these exit behaviors can be tested when the spinner program is called from another program or script:

$ make  # Build and run the small program with make

$ ./sit.sh  # Run the small program from a script