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:
parent
d194ce828d
commit
1d5a3507b2
1 changed files with 22 additions and 0 deletions
22
Userland/al.cpp
Normal file
22
Userland/al.cpp
Normal 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;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue