| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 |
<html><head> |
| 3 |
<title>liboop: on_signal(), cancel_signal()</title> |
| 4 |
<link rel="stylesheet" type="text/css" href="style.css"> |
| 5 |
</head><body> |
| 6 |
|
| 7 |
<h2>on_signal(), cancel_signal()</h2> |
| 8 |
|
| 9 |
<pre> |
| 10 |
#include <oop.h> |
| 11 |
#include <signal.h> |
| 12 |
|
| 13 |
/* <em>Callback function prototype.</em> */ |
| 14 |
typedef void *oop_call_signal(oop_source *source,int sig,void *user); |
| 15 |
|
| 16 |
/* <em>Register and unregister UNIX signal event sinks.</em> */ |
| 17 |
void (*on_signal)(oop_source *source,int sig,oop_call_signal *call,void *user); |
| 18 |
void (*cancel_signal)(oop_source *source,int sig,oop_call_signal *call,void *user); |
| 19 |
</pre> |
| 20 |
|
| 21 |
<h3>Arguments.</h3> |
| 22 |
|
| 23 |
<dl> |
| 24 |
<dt><b>oop_source *source</b> |
| 25 |
<dd>The event source to register or unregister the event sink with. This must |
| 26 |
be the same event source you got the function pointer from: |
| 27 |
"src->on_signal(src,...);".<p> |
| 28 |
|
| 29 |
<dt><b>int sig</b> |
| 30 |
<dd>The UNIX signal to monitor (SIGINT, SIGHUP, etc.).<p> |
| 31 |
|
| 32 |
<dt><b>oop_call_signal *call</b> |
| 33 |
<dd>The callback function (event sink) to add (or remove).<p> |
| 34 |
|
| 35 |
<dt><b>void *user</b> |
| 36 |
<dd>User data passed through to the callback function.<p> |
| 37 |
</dl> |
| 38 |
|
| 39 |
<h3>Description.</h3> |
| 40 |
|
| 41 |
Note that these are not global functions, but function pointers supplied |
| 42 |
by the event source (in the <em>oop_source</em> structure) or by the user. |
| 43 |
|
| 44 |
<dl> |
| 45 |
<dt><b>on_signal</b> |
| 46 |
<dd>After this function is called, if the signal <em>sig</em> is received, |
| 47 |
when the event loop next runs (immediately, if it is currently waiting for |
| 48 |
events), the event source will call the function <em>call</em>, passing it a |
| 49 |
pointer to the event source, the signal received, and the same opaque |
| 50 |
<em>user</em> pointer passed to on_signal. This callback will be called |
| 51 |
again if the signal occurs again, but if the signal is received multiple times |
| 52 |
in quick succession the event sink may only receive a single callback. |
| 53 |
Many callbacks may be registered for the same signal.<p> |
| 54 |
|
| 55 |
<dt><b>cancel_signal</b> |
| 56 |
<dd>Deactivate an event sink callback registered using on_signal (above). If |
| 57 |
the passed <em>sig</em>, <em>call</em> and <em>user</em> match a previously |
| 58 |
registered callback, it will be removed; if they match more than one, one of |
| 59 |
them will be removed; otherwise, no action is taken.<p> |
| 60 |
|
| 61 |
<dt><b>oop_call_fd</b> |
| 62 |
<dd>Called when the event is triggered. Performs a user_specific action. |
| 63 |
Should return OOP_CONTINUE if the event loop should continue operating; any |
| 64 |
other value (including OOP_HALT) will cause termination of the event loop. |
| 65 |
</dl> |
| 66 |
|
| 67 |
<hr><a href="ref.html">liboop reference</a></body></html> |