1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 23:17:46 +00:00

Userland: Add a little test program for the alarm() syscall.

This commit is contained in:
Andreas Kling 2019-06-07 11:30:22 +02:00
parent d194ce828d
commit 1d5a3507b2

22
Userland/al.cpp Normal file
View file

@ -0,0 +1,22 @@
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
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;
}