File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -81,7 +81,13 @@ char* myoptarg = NULL;
8181#define MAX_CERTS 16
8282
8383/* Simple logging macro */
84- #define LOG_ERROR (...) fprintf(stderr, __VA_ARGS__)
84+ #define LOG_ERROR (...) \
85+ do { \
86+ if (got_signal) \
87+ fprintf(stderr, "Shutdown requested, exiting loop\n"); \
88+ else \
89+ fprintf(stderr, __VA_ARGS__); \
90+ } while (0)
8591
8692#ifndef _WIN32
8793/* Signal handler flag */
@@ -811,8 +817,14 @@ THREAD_RETURN WOLFSSL_THREAD ocsp_responder_test(void* args)
811817
812818#ifndef _WIN32
813819 /* Install signal handlers for clean shutdown */
814- signal (SIGTERM , sig_handler );
815- signal (SIGINT , sig_handler );
820+ {
821+ struct sigaction sa ;
822+ memset (& sa , 0 , sizeof (sa ));
823+ sa .sa_handler = sig_handler ;
824+ /* Do NOT set SA_RESTART so accept() is interrupted */
825+ sigaction (SIGTERM , & sa , NULL );
826+ sigaction (SIGINT , & sa , NULL );
827+ }
816828 if (opts .verbose ) {
817829 printf ("Signal handlers installed\n" );
818830 }
You can’t perform that action at this time.
0 commit comments