mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-09 00:00:53 -04:00
utils: Provide a fallback for sigwaitinfo() if needed
Apparently, not available on Mac OS X 10.10 Yosemite. We don't provide this on Windows.
This commit is contained in:
parent
1c1f713431
commit
ef4279f2e5
@ -586,7 +586,7 @@ AC_CHECK_FUNC(
|
|||||||
)
|
)
|
||||||
|
|
||||||
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r)
|
AC_CHECK_FUNCS(prctl mallinfo getpass closefrom getpwnam_r getgrnam_r getpwuid_r)
|
||||||
AC_CHECK_FUNCS(fmemopen funopen mmap memrchr setlinebuf strptime dirfd)
|
AC_CHECK_FUNCS(fmemopen funopen mmap memrchr setlinebuf strptime dirfd sigwaitinfo)
|
||||||
|
|
||||||
AC_CHECK_FUNC([syslog], [
|
AC_CHECK_FUNC([syslog], [
|
||||||
AC_DEFINE([HAVE_SYSLOG], [], [have syslog(3) and friends])
|
AC_DEFINE([HAVE_SYSLOG], [], [have syslog(3) and friends])
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#ifndef ANDROID_H_
|
#ifndef ANDROID_H_
|
||||||
#define ANDROID_H_
|
#define ANDROID_H_
|
||||||
|
|
||||||
#include <android/api-level.h>
|
|
||||||
|
|
||||||
/* stuff defined in AndroidConfig.h, which is included using the -include
|
/* stuff defined in AndroidConfig.h, which is included using the -include
|
||||||
* command-line option, thus cannot be undefined using -U CFLAGS options.
|
* command-line option, thus cannot be undefined using -U CFLAGS options.
|
||||||
* the reason we have to undefine these flags in the first place, is that
|
* the reason we have to undefine these flags in the first place, is that
|
||||||
@ -30,30 +28,4 @@
|
|||||||
* actually defined. */
|
* actually defined. */
|
||||||
#undef HAVE_BACKTRACE
|
#undef HAVE_BACKTRACE
|
||||||
|
|
||||||
/* sigwaitinfo() is not defined up to this API level, provide a fallback */
|
|
||||||
#if __ANDROID_API__ <= 21
|
|
||||||
#include <errno.h>
|
|
||||||
#include <signal.h>
|
|
||||||
|
|
||||||
static inline int sigwaitinfo(const sigset_t *set, void *info)
|
|
||||||
{
|
|
||||||
int sig, err;
|
|
||||||
|
|
||||||
if (info)
|
|
||||||
{ /* we don't replicate siginfo_t, which we don't use */
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
err = sigwait(set, &sig);
|
|
||||||
if (err != 0)
|
|
||||||
{
|
|
||||||
errno = err;
|
|
||||||
sig = -1;
|
|
||||||
}
|
|
||||||
return sig;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#error Check availability of sigwaitinfo() in this API level
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /** ANDROID_H_ @}*/
|
#endif /** ANDROID_H_ @}*/
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
@ -126,7 +127,26 @@ void wait_sigint()
|
|||||||
sigwaitinfo(&set, NULL);
|
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
|
#ifndef HAVE_CLOSEFROM
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2008-2014 Tobias Brunner
|
* Copyright (C) 2008-2015 Tobias Brunner
|
||||||
* Copyright (C) 2008 Martin Willi
|
* Copyright (C) 2008 Martin Willi
|
||||||
* Hochschule fuer Technik Rapperswil
|
* Hochschule fuer Technik Rapperswil
|
||||||
*
|
*
|
||||||
@ -38,6 +38,7 @@
|
|||||||
# include <netinet/in.h>
|
# include <netinet/in.h>
|
||||||
# include <sched.h>
|
# include <sched.h>
|
||||||
# include <poll.h>
|
# include <poll.h>
|
||||||
|
# include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "utils/types.h"
|
#include "utils/types.h"
|
||||||
@ -151,6 +152,19 @@ void utils_deinit();
|
|||||||
*/
|
*/
|
||||||
#define ignore_result(call) { if(call){}; }
|
#define ignore_result(call) { if(call){}; }
|
||||||
|
|
||||||
|
#if !defined(HAVE_SIGWAITINFO) && !defined(WIN32)
|
||||||
|
/**
|
||||||
|
* Block and wait for a set of signals
|
||||||
|
*
|
||||||
|
* We don't replicate the functionality of siginfo_t. If info is not NULL
|
||||||
|
* -1 is returend and errno is set to EINVAL.
|
||||||
|
*
|
||||||
|
* @param set set of signals to wait for
|
||||||
|
* @param info must be NULL
|
||||||
|
*/
|
||||||
|
int sigwaitinfo(const sigset_t *set, void *info);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Portable function to wait for SIGINT/SIGTERM (or equivalent).
|
* Portable function to wait for SIGINT/SIGTERM (or equivalent).
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user