-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.c
More file actions
36 lines (26 loc) · 712 Bytes
/
main.c
File metadata and controls
36 lines (26 loc) · 712 Bytes
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
#include "slog.h"
#include "config.h"
#include "rtlmux.h"
#include <signal.h>
volatile unsigned char timeToExit = 0;
void signalExit(int sig) {
timeToExit = 1;
}
int main(int argc, char **argv) {
pthread_t threadServer;
parseConfig(argc, argv);
slog_init(NULL, NULL, LOG_EXTRA, LOG_DEBUG, 1);
struct sigaction sigact;
sigact.sa_handler = signalExit;
sigact.sa_flags = 0;
sigaction(SIGTERM, &sigact, NULL);
sigaction(SIGINT, &sigact, NULL);
do {
pthread_create(&threadServer, NULL, serverThread, NULL);
pthread_join(threadServer, NULL);
if (timeToExit == 2) {
slog(LOG_INFO, SLOG_INFO, "Restarting.");
timeToExit = 0;
}
} while (timeToExit != 1);
}