问题
I am trying to use SIGRTMIN signal to create blocking signalhandler in Android NDK.
int startThread(){
pthread_t thread;
sigset_t set;
/* Block SIGRTMIN other threads created by main()
will inherit a copy of the signal mask. */
sigemptyset(&set);
int rc = sigaddset(&set, SIGRTMIN);
__android_log_print(ANDROID_LOG_DEBUG, "LOG", "Return Code:%d",rc);
__android_log_print(ANDROID_LOG_DEBUG, "LOG", "Error Code:%d",errno);
pthread_sigmask(SIG_BLOCK, &set, NULL);
pthread_create(&thread, NULL, &sig_thread, (void *) &set);
}
static void *sig_thread(void *arg)
{
sigset_t *set = arg;
int s, sig;
for (;;) {
s = sigwait(set, &sig);
__android_log_print(ANDROID_LOG_DEBUG, "LOG", "Signal handling thread got signal %d\n", sig);
}
}
I am getting Return Code as -1 and Error code as 22 (EINVAL - Invalid Argument) while adding signal set sigaddset(&set, SIGRTMIN)
This is happening in x86
or armeabi-v7a
abi. If i use x86_64
then it works.
is there any way to solve this problem or any alternative in x86/armeabi-v7a
abi in Android?
来源:https://stackoverflow.com/questions/53481948/how-to-use-sigrtmin-in-x86-or-armeabi-v7a-abi-in-android-ndk