1
@comment $Id: glsignal.texi,v 1.5 2001/08/03 12:54:16 richi Exp $
3
@node GLAME Signal Interface, Function and Type Index, GLAME Database Interface, Top
4
@chapter GLAME Signal Interface
6
Generic signals via callbacks (@code{glsig_handler_t}), issuable from a
7
glsig_emitter. Signal masks are supported, as is a hierarchy of the
10
WARNING! No explicit threading support is included, i.e. do your own
11
locking (you have to protect the emitter against concurrent addition and
12
removal of handlers and emit of signals). Also a handler will be invoked
13
in the thread context of the emitter, not in the one which added the
14
handler. If you want to emit signals from real signal handlers you have
15
to ensure yourself that your handlers are signal safe - also they should
16
be reentrant as parallel invocation from different threads is not
19
Brief description of the available API follows:
21
@deftp void {(glsig_callb_t)} (glsig_handler_t *, long, va_list)
22
The type of the used callback functions through which signals
23
are supposed to be handled.
26
@tindex glsig_emitter_t
27
@deftypefun {} INIT_GLSIG_EMITTER ( glsig_emitter_t *@var{emitter})
28
Inits an emitter. No signal handlers are attached initially.
31
@tindex glsig_emitter_t
32
@tindex glsig_handler_t
34
@deftypefun {glsig_handler_t *} glsig_add_handler ( glsig_emitter_t *@var{emitter}, long @var{sigmask}, glsig_callb_t *@var{cb}, void *@var{priv})
35
Adds a signal handler to the emitter using the specified sigmask
36
and the callback handler. The priv data is stored in the handlers
37
->priv field which you should access using @code{glsig_handler_private()}.
40
@tindex glsig_emitter_t
41
@tindex glsig_handler_t
42
@deftypefun {glsig_handler_t *} glsig_add_redirector ( glsig_emitter_t *@var{emitter}, long @var{sigmask}, glsig_emitter_t *@var{dest})
43
Adds a redirector to the emitter. All signals raised from the emitter
44
matching the specified signal mask will be raised again from the dest emitt
47
@tindex glsig_emitter_t
48
@deftypefun void glsig_emit ( glsig_emitter_t *@var{emitter}, int @var{sig}, ...)
49
Emits the signal sig from the emitter and provides the varargs
50
to the callbacks. Signals are emitted bottom to top in the hierarchy.
51
It is safe to remove your signal handler during execution.
54
@tindex glsig_emitter_t
55
@deftypefun int glsig_copy_handlers ( glsig_emitter_t *@var{dest}, glsig_emitter_t *@var{source})
56
Copies all handlers from one emitter to another - same "private"
57
data, of course. Can return -1 on memory shortage. Redirectors are
61
@tindex glsig_emitter_t
62
@deftypefun int glsig_copy_redirectors ( glsig_emitter_t *@var{dest}, glsig_emitter_t *@var{source})
63
Copies all redirectors from one emitter to another - same "private"
64
data, of course. Can return -1 on memory shortage. Normal handlers
68
@tindex glsig_handler_t
69
@deftypefun void glsig_delete_handler ( glsig_handler_t *@var{handler})
70
Removes and destroyes the specified handler from its emitter.
73
@tindex glsig_emitter_t
74
@deftypefun void glsig_delete_all ( glsig_emitter_t *@var{emitter})
75
Removes and destroyes all signal handlers from the specified emitter.
79
@tindex glsig_handler_t
80
@deftypefun void glsig_handler_exec ( glsig_handler_t *@var{h}, int @var{sig}, ...)
81
Executes the specified signal handler. Usually you dont want to use
82
this, instead use @code{glsig_emit()}.
86
Inside signal handlers you may access the passed parameters (which you
87
should know by type and count) with the following macros.
89
@deftypefun void GLSIGH_GETARGS1 ( va_list @var{va}, type1 @var{var1})
90
@deftypefunx void GLSIGH_GETARGS2 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2})
91
@deftypefunx void GLSIGH_GETARGS3 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2}, type3 @var{var3})
92
@deftypefunx void GLSIGH_GETARGS4 ( va_list @var{va}, type1 @var{var1}, type2 @var{var2}, type3 @var{var3}, type4 @var{var4})
93
These macros initialize the provided variables with the passed parameters.
94
Beware that passing types with @code{sizeof(type)} not equal to
95
@code{sizeof(void *)} is not safe on compilers other than gcc.