FTAM/9000 Programmer's Guide

Chapter 4 187
Using Support Functions
Responding to Asynchronous Calls
/* Install the signal handler for the signal you want to trap. */
vec.sv_handler = signal_handler;
vec.sv_mask = 0;
vec.sv_flags = 0;
sigvector(signal_you_want_to_trap, & vec, NULL);
/* Initiate the asynchronous FTAM operations. The code for
** initiating these operations is not shown in this example.
*/
/* Wait for a MAP operation to complete or a signal to be caught.
** This is done by blocking on both MAP events and the sig_pipe
** to become readable.
*/
readfds[0] = 0;
readfds[1] = 0;
SET_MASK(sig_pipe[READ], readfds);
nfds = sig_pipe[READ] + 1;
map_rc = em_hp_select(FOREVER, & map_event, & nfds, readfds, NULL, NULL,
& map_result);
if ((map_rc == SUCCESS) || (map_rc == EME032_IPC_ERROR))
{
if (map_event != 0)
{
/* Process the results of the completed MAP operation. The
** code for this function is not shown in this example.
*/
map_operation_completed(map_event, map_rc);
}
if (TST_MASK(sig_pipe[READ], readfds))
{
/* em_hp_select() was interrupted by a signal. Remove the signal
** value from the pipe to clear the interrupt notification.
*/
read(sig_pipe[READ], & sigval, sizeof(int));
/* Perform the application specific logic to be done when
** em_hp_select() unblocks because of a signal.
*/
}
}
else
{
/* Handle the em_hp_select() error. See Example 1. */
}