Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/uloop-example.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/uloop-example.lua b/examples/uloop-example.lua
index f3aef60..1b73aed 100755
--- a/examples/uloop-example.lua
+++ b/examples/uloop-example.lua
@@ -63,6 +63,22 @@ uloop.timer(
end, 2000
)
+-- SIGINT handler
+uloop.signal(function(signo)
+ print(string.format("Terminating on SIGINT (#%d)!", signo))
+
+ -- end uloop to terminate program
+ uloop.cancel()
+end, uloop.SIGINT)
+
+local sig
+sig = uloop.signal(function(signo)
+ print(string.format("Got SIGUSR2 (#%d)!", signo))
+
+ -- remove signal handler, next SIGUSR2 will terminate program
+ sig:delete()
+end, uloop.SIGUSR2)
+
-- Keep udp_ev reference, events will be gc'd, even if the callback is still referenced
-- .delete will manually untrack.
udp_ev = uloop.fd_add(udp, function(ufd, events)