From: Tobias Brunner Date: Wed, 22 Feb 2023 13:29:39 +0000 (+0100) Subject: utils: Add counterpart to wait_sigint() to explicitly stop waiting X-Git-Tag: 5.9.10rc1~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=18d73a9a5c0f17ddc4fb12942df2fa0db20e42b5;p=thirdparty%2Fstrongswan.git utils: Add counterpart to wait_sigint() to explicitly stop waiting --- diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c index 4228b1f512..ccab4062ef 100644 --- a/src/libstrongswan/utils/utils.c +++ b/src/libstrongswan/utils/utils.c @@ -111,6 +111,14 @@ void wait_sigint() sigint_cond->destroy(sigint_cond); } +/** + * Windows variant + */ +void send_sigint() +{ + handler(CTRL_C_EVENT); +} + #else /* !WIN32 */ /** @@ -131,6 +139,14 @@ void wait_sigint() } } +/** + * Unix variant + */ +void send_sigint() +{ + kill(0, SIGINT); +} + #ifndef HAVE_SIGWAITINFO int sigwaitinfo(const sigset_t *set, void *info) { diff --git a/src/libstrongswan/utils/utils.h b/src/libstrongswan/utils/utils.h index 083f553441..a5a5faacb5 100644 --- a/src/libstrongswan/utils/utils.h +++ b/src/libstrongswan/utils/utils.h @@ -237,6 +237,12 @@ int sigwaitinfo(const sigset_t *set, void *info); */ void wait_sigint(); +/** + * Portable function to send a SIGINT/SIGTERM (or equivalent) to the current + * process to exit the above function. + */ +void send_sigint(); + #ifndef HAVE_CLOSEFROM /** * Close open file descriptors greater than or equal to lowfd.