diff options
Diffstat (limited to 'tests/test-sigtimedwait.lua')
-rw-r--r-- | tests/test-sigtimedwait.lua | 37 |
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 |