2 .TH sel 3 "23 July 1999" "Straylight/Edgeware" "mLib utilities library"
4 sig \- more controlled signal handling
10 .B "#include <mLib/sig.h>"
12 .B "typedef struct { ...\& } sig;"
14 .ta \w'\fBvoid sig_add('u
15 .BI "void sig_add(sig *" s ", int " n ,
16 .BI " void (*" proc ")(int " n ", void *" p "), void *" p );
17 .BI "void sig_remove(sig *" s );
18 .BI "void sig_init(sel_state *" s );
23 subsystem uses the I/O multiplexing capabilities of
27 for details) to provide a more convenient interface for handling signals
28 which don't need to be dealt with `right away'. Like the I/O system,
30 doesn't allocate any memory for itself: you have to give it space to
33 The system needs to be initialized before use. To do this, you must
36 passing it the address of an initialized multiplexor object. Signals
37 handled through this interface will only be delivered when
39 is called on that multiplexor.
41 To register interest in a signal, call
43 passing it the following arguments:
46 A pointer to an (uninitialized) object of type
48 This will be used by the system to retain information about this signal
49 claim. You use the address of this object to remove the handler again
53 The number of the signal you want to handle.
56 .BI "void (*" proc ")(int " n ", void *" p )
57 A function to call when the signal is detected. The function is passed
58 the signal number and the pointer
64 A pointer argument to be passed to
66 when the signal is detected.
68 Removing a handler is easy. Call
70 with the address of the
72 structure you passed to
74 .SS "Multiple signal handlers"
75 You may have multiple signal handlers for a signal. All of them are
76 called in some unspecified order when the signal occurs.
78 A signal's disposition is remembered when a handler for it is added and
79 there are no handlers already registered. When the last handler for a
80 signal is removed, its disposition is restored to its initial remembered
82 .SH "BUGS AND CAVEATS"
85 system attempts to set the
87 flag on signal handlers it creates that signal occurrences don't
88 interrupt system calls. This won't be done on systems which don't
89 define this flag, for obvious reasons.
93 flag is also set, so that stopped child processes aren't reported by a
94 signal. This is normally right, but ought to be configurable.
96 Mark Wooding, <mdw@distorted.org.uk>