blob: 3882e56e4d6bd52fced475bd208b61c8f391e002 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include <AK/StdLibExtras.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
static volatile bool got_alarm = false;
int main(int argc, char** argv)
{
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;
}
|