This is an appendix to Understanding Unix/Linux Programming written for people interested in Ada programming on POSIX systems.

Programming for Humans: Terminal Control and Signals

Section 6.2, page 172

You can find the short translation program as rotate.adb.

Section 6.2.1, page 172

Compile the program, and run it using the default settings: (<- is backspace)

% gnatmake -P rotate
% ./rotate

Section 6.2.2, page 174

The second example here should be run from /bin/sh or another low-tech shell.

Section 6.3, page 176-181

The version which just does the job: play_again0.adb

The version which gives immediate response: play_again1.adb

The version which ignores illegal keys: play_again2.adb

Section 6.3.1, page 181-185

The version which ignores illegal keys: play_again3.adb

Section 6.4, page 185

Since signal handling using function signal() is thread unsafe, this isn't a part of POSIX/Ada. For the sake of completing the examples in this chapter, I have created a binding to these unsafe functions in package C_Signals. Once we have covered how to write parallel programs, we will take a look at the proper, thead-safe methods in package POSIX.Signals.

Section 6.4.4, page 188-189

You can find the first simple signal handling program here: sigdemo1.adb

You can find the second simple signal handling program here: sigdemo2.adb

Notice that these two programs use package C_Signals which only works for single-threaded (non-parallel) programs.

Section 6.5, page 191-193

The version which catches signals, resets the driver, and returns a negative result: play_again4.adb


Go to next chapter.

Collected examples:
Based on:
Understanding Unix/Linux Programming, Bruce Molay, ISBN 0-13-008396-8.
Main page:
Written by:
Jacob Sparre Andersen.
Latest update:
19th of April, 2008