]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
utils: Add counterpart to wait_sigint() to explicitly stop waiting
authorTobias Brunner <tobias@strongswan.org>
Wed, 22 Feb 2023 13:29:39 +0000 (14:29 +0100)
committerTobias Brunner <tobias@strongswan.org>
Wed, 22 Feb 2023 13:33:34 +0000 (14:33 +0100)
src/libstrongswan/utils/utils.c
src/libstrongswan/utils/utils.h

index 4228b1f512ed2858a3af7fec34ef677473b54026..ccab4062ef3edc05adb16bcc01af9992ca1a9d96 100644 (file)
@@ -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)
 {
index 083f5534410859aa0648cb2c01c283c8b146b45d..a5a5faacb5192f9dcc7f5f3291443cd97c862f21 100644 (file)
@@ -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.