Signals - VeriFone MX800 series Programmer's Manual

Hide thumbs Also See for MX800 series:
Table of Contents

Advertisement

D
D
EVICE
RIVERS

Signals

Signals
114
M
X
800 S
P
ERIES
ROGRAMMERS
Signals are present in practically all Unix/Linux systems and are a mechanism to
inform processes of an event that has occurred. Signals have default behavior
and documentation on all the signals available and their default actions can be
found in practically any Linux/Unix programming book. If an application would like
to be informed of an event that there is a signal available for, then the application
can define a handler that would be executed upon receipt of that particular signal.
This allows the application to "trap" on events and handle them as desired. The
x
M
800 series of terminals has the ability to use signals. As long as that event is
triggered by the OS or any application, then an application can define a handler to
trap on the desired signal. An example of this would be the SIGINT signal which is
issued whenever an interrupt is received. A common way to receive an interrupt is
when the user presses Ctrl-C on the keyboard. A way to trap on this event would
be to add the following code to the application:
void sigHandler(void)
{
printf("Got Interrupt Signal!\n");
...do desired cleanup stuff here...
exit(0);
}
int main(void)
{
struct sigaction mySig;
int i;
mySig.sa_handler = (void *)sigHandler;
sigemptyset(&mySig.sa_mask);
mySig.sa_flags = 0;
i = sigaction(SIGINT, &mySig, 0);
}
One of the restrictions of using signals is that there can only be one handler per
process and all of its child process' – this includes processes created by fork()
and any thread that is spawned with pthread_create(). The application
programmer should be aware that any handler that they create for a particular
signal would also have to handle that signal issued by any threads created by that
application. Likewise, there are also M
signals. If an application links with this library and also wants to use the same
signal then there has to be a mechanism to determine which process sent the
signal and what action to take. The M
implemented two such mechanisms for the SIGIO and SIGALRM signals. These
signals inform an application when any I/O of data has occurred on a particular
device and when an Alarm event has occurred, respectively.
G
UIDE
x
800 series terminal libraries that use
x
800 series of terminals OS has

Advertisement

Table of Contents
loading

Table of Contents