toaruos/apps/test-sigwait.c

29 lines
512 B
C
Raw Normal View History

2022-08-18 10:56:43 +03:00
#include <stdio.h>
#include <signal.h>
#include <errno.h>
#include <string.h>
void handler(int sig) {
fprintf(stderr, "received %d\n", sig);
}
int main(int argc, char * argv[]) {
signal(SIGINT, handler);
signal(SIGWINCH, handler);
sigset_t mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigprocmask(SIG_BLOCK, &mask, NULL);
while (1) {
int sig = 0;
int result = sigwait(&mask, &sig);
fprintf(stderr, "result = %d, sig = %d, errno = %s\n", result, sig, strerror(errno));
}
return 0;
}