client.c, coap-server.c: use signal instead of sigaction on win32

This commit is contained in:
Jean-Claude Michelou authored and Olaf Bergmann committed 2019-03-02 22:10:07 +01:00
1 parent 8c5724c712
commit 34679ff5cb
2 files changed
+12

No files matched your search

+6
View File
@@ -1236,7 +1236,9 @@ main(int argc, char **argv) {
unsigned char user[MAX_USER + 1], key[MAX_KEY];
ssize_t user_length = 0, key_length = 0;
int create_uri_opts = 1;
#ifndef _WIN32
struct sigaction sa;
#endif
while ((opt = getopt(argc, argv, "NrUa:b:c:e:f:k:m:p:s:t:o:v:A:B:C:O:P:R:T:u:l:K:")) != -1) {
switch (opt) {
@@ -1458,12 +1460,16 @@ main(int argc, char **argv) {
wait_ms = wait_seconds * 1000;
coap_log(LOG_DEBUG, "timeout is set to %u seconds\n", wait_seconds);
#ifdef _WIN32
signal(SIGINT, handle_sigint);
#else
memset (&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = handle_sigint;
sa.sa_flags = 0;
sigaction (SIGINT, &sa, NULL);
sigaction (SIGTERM, &sa, NULL);
#endif
while (!quit && !(ready && coap_can_exit(ctx)) ) {
+6
View File
@@ -951,7 +951,9 @@ main(int argc, char **argv) {
coap_log_t log_level = LOG_WARNING;
unsigned wait_ms;
time_t t_last = 0;
#ifndef _WIN32
struct sigaction sa;
#endif
clock_offset = time(NULL);
@@ -1030,12 +1032,16 @@ main(int argc, char **argv) {
if (group)
join(ctx, group);
#ifdef _WIN32
signal(SIGINT, handle_sigint);
#else
memset (&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = handle_sigint;
sa.sa_flags = 0;
sigaction (SIGINT, &sa, NULL);
sigaction (SIGTERM, &sa, NULL);
#endif
wait_ms = COAP_RESOURCE_CHECK_TIME * 1000;