ladybird/Userland/al.cpp

27 lines
572 B
C++
Raw Normal View History

2019-06-22 13:47:08 +00:00
#include <AK/StdLibExtras.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
static volatile bool got_alarm = false;
2019-06-22 13:47:08 +00:00
int main(int argc, char** argv)
{
2019-06-22 13:47:08 +00:00
UNUSED_PARAM(argc);
UNUSED_PARAM(argv);
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;
}