-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaturnd.c
52 lines (40 loc) · 993 Bytes
/
saturnd.c
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <signal.h>
#include <poll.h>
#include <unistd.h>
#include <netlink/socket.h>
#include <netlink/genl/mngt.h>
#include <libudev.h>
#include "netlinkcom.h"
#include "algsocket.h"
static void handleSIGINT(int sig);
struct udev *udevctx = NULL;
int algsocket = -1;
static volatile int run = 1;
int main(int argc, char **argv) {
int err;
//nl_debug = 4;
signal(SIGINT, handleSIGINT);
udevctx = udev_new();
algsocket = alg_getsock();
struct nl_sock *nlsock = com_init();
struct pollfd pfd = {
.fd = nl_socket_get_fd(nlsock),
.events = POLLIN,
};
while(run) {
if(poll(&pfd, 1, 5000) > 0) {
err = nl_recvmsgs_default(nlsock);
if(err) {
printf("nl recv error: %s\n", nl_geterror(err));
break;
}
}
}
com_cleanup(nlsock);
udev_unref(udevctx);
close(algsocket);
return 0;
}
static void handleSIGINT(int sig) {
run = 0;
}