npth change required for Android

NIIBE Yutaka gniibe at fsij.org
Mon Dec 9 03:47:42 CET 2013


For the issue 1576 (reported by Hans Christoph Steiner), I write
a patch for Npth.

OK to commit?


[0] https://bugs.g10code.com/gnupg/issue1576

--------------
diff --git a/configure.ac b/configure.ac
index bd650c7..2a0216f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -256,6 +256,7 @@ if test "$have_w32_system" = no; then
     AC_CHECK_FUNCS([pthread_rwlock_rdlock pthread_rwlock_wrlock])
     AC_CHECK_FUNCS([pthread_rwlock_timedrdlock pthread_rwlock_timedwrlock])
     AC_CHECK_FUNCS([pthread_rwlock_tryrdlock pthread_rwlock_trywrlock])
+    AC_CHECK_FUNCS([pthread_atfork])
   fi
 fi
 
diff --git a/src/npth-sigev.c b/src/npth-sigev.c
index aab977e..78e92ff 100644
--- a/src/npth-sigev.c
+++ b/src/npth-sigev.c
@@ -126,12 +126,16 @@ npth_sigev_add (int signum)
 }
 

+#ifdef HAVE_PTHREAD_ATFORK
+/* There is non-POSIX operating system where fork is not available to
+   applications.  There, we have no pthread_atfork either.  In such a
+   case, we don't call pthread_atfork.  */
 static void
 restore_sigmask_for_child_process (void)
 {
   pthread_sigmask (SIG_SETMASK, &sigev_unblock, NULL);
 }
-
+#endif
 
 /* Finish the list of watched signals.  This starts to block them,
    too.  */
@@ -140,7 +144,9 @@ npth_sigev_fini (void)
 {
   /* Block the interesting signals.  */
   pthread_sigmask (SIG_SETMASK, &sigev_block, NULL);
+#ifdef HAVE_PTHREAD_ATFORK
   pthread_atfork (NULL, NULL, restore_sigmask_for_child_process);
+#endif
 }
 

-- 





More information about the Gnupg-devel mailing list