#include <lcsignal.h> int ecbpause(int mask, size_t listsize, struct _ecblist *ecblist);
ecbpause
delays program execution until it receives a C signal
or an Event Control Block (ECB) is posted. mask
specifies
the mask of signals managed by SAS/C to be blocked while execution is delayed.
listsize
specifies the number of _ecblist
structures addressed
by the ecblist
argument.
ecblist
is the address of an array of structures, each of which
represents one or more contiguous ECBs. Each structure contains two members:
a count of the number of ECBs and the address of an array of ECBs. The
count may be zero, in which case the ECB array address is ignored.
The declaration for the _ecblist
structure is:
struct _ecblist { size_t count; unsigned *ecbarr; }
The ECB list for ecbpause
is passed by the _ecblist
structure for several reasons. It enables a static ECB list to be used
in many cases since individual ECBs can easily be removed by setting
their count
member to 0. For applications that have a large
number of ECBs, the _ecblist
structure facilitates organizing
them into arrays; this method may slightly improve the performance of
ecbpause
because fewer memory accesses are required to determine the
addresses of all the ECBs.
ecbpause
returns to its caller when one of the following events occurs:
ecbpause
.
Several conditions for completion of the ecbpause
function may occur
simultaneously or nearly simultaneously. In such cases, a signal
handler may be called even though an ECB was POSTed before or during
arrival of the signal. On return from ecbpause
, any number of ECBs
may be POSTed, and more than one signal handler may have been called if the
signal mask permits it.
ecbpause
returns the errno
value EINTR
if an unblocked
signal was pending at the completion of its wait. Otherwise, it returns
zero.
ecbpause
does not clear any ECBs addressed with the ecblist
argument. It is the caller's responsibility to clear the ECBs after a POST
and to initialize them to zero or to some other suitable value.
The value returned by ecbpause
may not be completely reliable.
An ECB may have been POSTed even though a signal was detected, and a
signal may have been received after ecbpause
was awakened by a
POST but before return to the user program was completely effected.
ecbpause
does not permit the caller to change the signal mask for
any signals managed by OpenEdition. Programs that handle OpenEdition
signals should use the ecbsuspend
function instead.
ecbpause
builds a standard OS ECB list for the ECBs indicated
by its arguments, in addition to an ECB used internally by signal
handling, and issues the OS WAIT macro to wait for a single ECB to be
POSTed.
SIGALRM
is not managed
by OpenEdition. See the sigsuspend
example for a version that
works regardless of whether SIGALRM
is managed by
OpenEdition.
#include <lcsignal.h> #include <ctype.h> /* flag for SIGALRM handler * static int toolate = 0; static void timesup(int signum); int confirm() { unsigned ECB = 0; struct _ecblist myECBs = {1, 0 } ; char reply; /* Set up ECB list for single ECB. */ myECBs.ecbarr = &ECB; /* Issue WTOR macro via assembler. */ /* subroutine (not shown) */ wtor("Reply U to confirm request.", &reply, &ECB); /* Catch SIGALRM signal. */ signal(SIGALRM, ×up); toolate = 0; /* Wait 2 minutes for reply. */ alarm(120); ecbpause(0, 1, &myECBs); /* Cancel alarm. */ alarm(0); /* Restore default alarm handling. */ signal(SIGALRM, SIG_DFL); /* If the ECB was posted, */ /* return whether OK given. */ if (ECB & 0x40000000) return toupper(reply) == 'U'; /* If we ran out of time, */ /* call asm to delete reply. */ else if(toolate){ dom(); /* Tell caller not to do it. */ puts("No reply received, treated as permission denied. "); return 0; } } static void timesup(int signum) { toolate = 1; return; }
ecbsuspend
, sigpause
, sigsuspend
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.