yggdrasil/test.c

34 lines
770 B
C
Raw Normal View History

2024-11-20 15:39:10 +02:00
#include <sys/time.h>
#include <unistd.h>
#include <signal.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
static void silence_sigint(int signum) {}
2024-11-15 23:18:04 +02:00
int main(int argc, const char **argv) {
2024-11-20 15:39:10 +02:00
signal(silence_sigint, SIGINT);
struct timespec duration;
struct timespec remaining;
while (1) {
duration.tv_sec = 3;
duration.tv_nsec = 0;
int result = nanosleep(&duration, &remaining);
if (result != 0) {
assert(errno == EINTR);
printf(
"EINTR: remaining: sec=%lu, nsec=%u\n",
(unsigned long) remaining.tv_sec,
(unsigned int) remaining.tv_nsec
);
} else {
printf("NO EINTR\n");
}
}
2024-11-11 15:19:36 +02:00
return 0;
}