summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils/utils.c')
-rw-r--r--src/libstrongswan/utils/utils.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/libstrongswan/utils/utils.c b/src/libstrongswan/utils/utils.c
index b4a4db802..47d72ee98 100644
--- a/src/libstrongswan/utils/utils.c
+++ b/src/libstrongswan/utils/utils.c
@@ -20,6 +20,7 @@
#include <unistd.h>
#include <limits.h>
#include <ctype.h>
+#include <errno.h>
#ifndef WIN32
# include <signal.h>
#endif
@@ -117,17 +118,35 @@ void wait_sigint()
void wait_sigint()
{
sigset_t set;
- int sig;
sigemptyset(&set);
sigaddset(&set, SIGINT);
sigaddset(&set, SIGTERM);
sigprocmask(SIG_BLOCK, &set, NULL);
- sigwait(&set, &sig);
+ sigwaitinfo(&set, NULL);
}
-#endif
+#ifndef HAVE_SIGWAITINFO
+int sigwaitinfo(const sigset_t *set, void *info)
+{
+ int sig, err;
+
+ if (info)
+ { /* we don't replicate siginfo_t, fail if anybody tries to use it */
+ errno = EINVAL;
+ return -1;
+ }
+ err = sigwait(set, &sig);
+ if (err != 0)
+ {
+ errno = err;
+ sig = -1;
+ }
+ return sig;
+}
+#endif /* HAVE_SIGWAITINFO */
+#endif /* WIN32 */
#ifndef HAVE_CLOSEFROM
/**