Block TIMER_SIGNAL in sigprocmask(SIG_SETMASK, ...).

Previously, we were zeroing out the reserved signals, when we actually
wanted to have TIMER_SIGNAL always be blocked, and the other signals
always be unblocked. This resulted in process termination when a
SIGEV_THREAD timer callback calls sigprocmask(SIG_SETMASK, ...) with
any signal mask value, and then subsequently fails to complete its
callback and reach the sigtimedwait in bionic before the next timer
iteration triggers.

Add a how argument to filter_reserved_signals to appropriately
block/unblock our reserved signals.

Bug: http://b/116783733
Test: bionic-unit-tests32/64
Change-Id: Ie5339682cdeb914711cd4089cd26ee395704d0df
diff --git a/tests/spawn_test.cpp b/tests/spawn_test.cpp
index a5e7e56..04b66d3 100644
--- a/tests/spawn_test.cpp
+++ b/tests/spawn_test.cpp
@@ -396,7 +396,13 @@
   // Check that's what happens...
   ProcStatus ps = {};
   GetChildStatus(&sa, &ps);
-  EXPECT_EQ(static_cast<uint64_t>(1 << (SIGALRM - 1)), ps.sigblk);
+
+  // TIMER_SIGNAL should also be blocked.
+  uint64_t expected_blocked = 0;
+  SignalSetAdd(&expected_blocked, SIGALRM);
+  SignalSetAdd(&expected_blocked, __SIGRTMIN + 0);
+  EXPECT_EQ(expected_blocked, ps.sigblk);
+
   EXPECT_EQ(static_cast<uint64_t>(0), ps.sigign);
 
   ASSERT_EQ(0, posix_spawnattr_destroy(&sa));
@@ -421,8 +427,15 @@
   // Check that's what happens...
   ProcStatus ps = {};
   GetChildStatus(&sa, &ps);
-  EXPECT_EQ(static_cast<uint64_t>(0), ps.sigblk);
-  EXPECT_EQ(static_cast<uint64_t>(1 << (SIGCONT - 1)), ps.sigign);
+
+  // TIMER_SIGNAL should be blocked.
+  uint64_t expected_blocked = 0;
+  SignalSetAdd(&expected_blocked, __SIGRTMIN + 0);
+  EXPECT_EQ(expected_blocked, ps.sigblk);
+
+  uint64_t expected_ignored = 0;
+  SignalSetAdd(&expected_ignored, SIGCONT);
+  EXPECT_EQ(expected_ignored, ps.sigign);
 
   ASSERT_EQ(0, posix_spawnattr_destroy(&sa));
 }