3 .\" Manual for in-band signal handling
5 .\" (c) 1999, 2001, 2005, 2009, 2023, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH sel 3mLib "23 July 1999" "Straylight/Edgeware" "mLib utilities library"
36 .\"--------------------------------------------------------------------------
38 sig \- more controlled signal handling
40 .\"--------------------------------------------------------------------------
44 .B "#include <mLib/sig.h>"
46 .B "typedef struct { ...\& } sig;"
48 .ta \w'\fBvoid sig_add('u
49 .BI "void sig_add(sig *" s ", int " n ,
50 .BI " void (*" proc ")(int " n ", void *" p "), void *" p );
51 .BI "void sig_remove(sig *" s );
52 .BI "void sig_init(sel_state *" s );
55 .\"--------------------------------------------------------------------------
60 subsystem uses the I/O multiplexing capabilities of
64 for details) to provide a more convenient interface for handling signals
65 which don't need to be dealt with `right away'. Like the I/O system,
67 doesn't allocate any memory for itself: you have to give it space to
70 The system needs to be initialized before use. To do this, you must
73 passing it the address of an initialized multiplexor object. Signals
74 handled through this interface will only be delivered when
76 is called on that multiplexor.
78 To register interest in a signal, call
80 passing it the following arguments:
83 A pointer to an (uninitialized) object of type
85 This will be used by the system to retain information about this signal
86 claim. You use the address of this object to remove the handler again
90 The number of the signal you want to handle.
93 .BI "void (*" proc ")(int " n ", void *" p )
94 A function to call when the signal is detected. The function is passed
95 the signal number and the pointer
101 A pointer argument to be passed to
103 when the signal is detected.
105 Removing a handler is easy. Call
107 with the address of the
109 structure you passed to
112 .SS "Multiple signal handlers"
113 You may have multiple signal handlers for a signal. All of them are
114 called in some unspecified order when the signal occurs.
116 A signal's disposition is remembered when a handler for it is added and
117 there are no handlers already registered. When the last handler for a
118 signal is removed, its disposition is restored to its initial remembered
121 .\"--------------------------------------------------------------------------
122 .SH "BUGS AND CAVEATS"
126 system attempts to set the
128 flag on signal handlers it creates that signal occurrences don't
129 interrupt system calls. This won't be done on systems which don't
130 define this flag, for obvious reasons.
134 flag is also set, so that stopped child processes aren't reported by a
135 signal. This is normally right, but ought to be configurable.
137 .\"--------------------------------------------------------------------------
144 .\"--------------------------------------------------------------------------
147 Mark Wooding, <mdw@distorted.org.uk>
149 .\"----- That's all, folks --------------------------------------------------