summaryrefslogtreecommitdiff
path: root/tests/test-sigtimedwait.lua
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@vx21.xyz>2019-10-04 23:28:49 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2019-10-06 09:22:07 +0100
commit4c42af5fd9b2bb8cc2c37c71314b8c443cf80392 (patch)
treec3993b270ccdfa757ba310c42da0ae7c5b9d9351 /tests/test-sigtimedwait.lua
parentedeef019e8ad8b60f0547a854dc7763f98ff4c40 (diff)
downloadluxio-4c42af5fd9b2bb8cc2c37c71314b8c443cf80392.tar.bz2
Add sigpending, sigsuspend, sigwait, sigwaitinfo, sigtimedwait and raise
Diffstat (limited to 'tests/test-sigtimedwait.lua')
-rw-r--r--tests/test-sigtimedwait.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test-sigtimedwait.lua b/tests/test-sigtimedwait.lua
new file mode 100644
index 0000000..0311a50
--- /dev/null
+++ b/tests/test-sigtimedwait.lua
@@ -0,0 +1,37 @@
+local l = require "luxio"
+
+function handler()
+ return
+end
+
+l.sigaction(l.SIGINT, {["sa_handler"] = handler})
+
+s = l.newsigset()
+l.sigemptyset(s)
+l.sigaddset(s, l.SIGINT)
+
+info, errno = l.sigtimedwait(s, 0, 0)
+
+if not (info == nil and errno == l.EAGAIN) then
+ print("FAIL")
+end
+
+print("Wait...")
+pid, errno = l.fork()
+if pid == 0 then
+ l.sleep(5)
+ print("Press CTRL-C...")
+ os.exit(0)
+elseif pid == -1 then
+ io.stderr:write(("fork: %s\n"):format(l.strerror(errno)))
+ os.exit(2)
+end
+
+seconds = 3600
+info, errno = l.sigtimedwait(s, seconds, 0)
+
+if info ~= nil and info["si_signo"] == l.SIGINT then
+ print("PASS")
+else
+ print(("FAIL (expected sig to be %d but it is %d)"):format(l.SIGINT, info["si_signo"]))
+end