diff --git a/examples/client.c b/examples/client.c index 8c560e44..4d3e4c79 100644 --- a/examples/client.c +++ b/examples/client.c @@ -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)) ) { diff --git a/examples/coap-server.c b/examples/coap-server.c index 6ee4b450..ee8bc3fb 100644 --- a/examples/coap-server.c +++ b/examples/coap-server.c @@ -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;