This is an appendix to Understanding Unix/Linux
Programming
written for people interested in Ada programming on POSIX
systems.
The first program shows the basic logic of a curses program: hello1.adb.
Compiling and running the program is easy:
% gnatmake -P hello1 % ./hello1
[...] Predict the output of this second example: hello2.adb.
Note that neither alarm() nor pause() have
direct equivalents in POSIX/Ada. To make the functioning of the examples
more obvious I have made function Alarm and procedure
Pause available in package C_Signals.
[...] We combine these ideas to write the program sleep1.adb.
In Ada the delay statement does the job of
both the sleep() and the usleep() function.
The program ticker_demo.adb demonstrates the use of an interval timer.
Compile and run sigdemo3.adb to learn how processes on your system respond to combinations of signals.
Procedure Send_Signal in
package POSIX.Signals sends a signal to a
process.
sigprocmaskSkip this. It is strictly for single threaded programs.
You can of course use delay
statements also for fine-grained pauses, so there is no need to look
into usleep.
[...] (Hint: Read the section Delay Statements, Duration, and
Time
in the Ada Reference Manual.)
Go to next chapter.
Understanding Unix/Linux Programming, Bruce Molay,
ISBN 0-13-008396-8.