From 1d5a3507b2deb7d23ba0427aacac6805d7acf5ac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 7 Jun 2019 11:30:22 +0200 Subject: [PATCH] Userland: Add a little test program for the alarm() syscall. --- Userland/al.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Userland/al.cpp diff --git a/Userland/al.cpp b/Userland/al.cpp new file mode 100644 index 0000000000..d5b2cad0fd --- /dev/null +++ b/Userland/al.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +static volatile bool got_alarm = false; + +int main(int c, char** v) +{ + unsigned ret = alarm(5); + printf("alarm() with no alarm set: %u\n", ret); + ret = alarm(2); + printf("alarm() with an alarm(5) set: %u\n", ret); + + signal(SIGALRM, [] (int) { + got_alarm = true; + }); + printf("Entering infinite loop.\n"); + while (!got_alarm) { + } + printf("Oh, we got the alarm. Exiting :)\n"); + return 0; +}