Better handling of sigset_t on LP32.
The main motivation here is that the sigprocmask in pthread_exit wasn't
actually blocking the real-time signals, and debuggerd (amongst other
things) is using them. I wasn't able to write a test that actually won
that race but I did write an equivalent one for posix_spawn.
This also fixes all the uses of sigset_t where the sigset_t isn't
exposed to the outside (which we can't easily fix because it would be
an ABI change).
Bug: https://issuetracker.google.com/72291624
Test: ran tests
Change-Id: Ib6eebebc5a7b0150079f1cb79593247917dcf750
diff --git a/libc/bionic/sigsetmask.c b/libc/bionic/sigsetmask.c
index 7842bf1..6a3b1d2 100644
--- a/libc/bionic/sigsetmask.c
+++ b/libc/bionic/sigsetmask.c
@@ -25,26 +25,18 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
+
#include <signal.h>
-/* called from setjmp assembly fragment */
-int
-sigsetmask(int mask)
-{
- int n;
+int sigsetmask(int mask) {
+ union {
+ int mask;
+ sigset_t set;
+ } in, out;
- union {
- int the_mask;
- sigset_t the_sigset;
- } in, out;
+ sigemptyset(&in.set);
+ in.mask = mask;
- sigemptyset(&in.the_sigset);
- in.the_mask = mask;
-
- n = sigprocmask(SIG_SETMASK, &in.the_sigset, &out.the_sigset);
- if (n)
- return n;
-
- return out.the_mask;
+ if (sigprocmask(SIG_SETMASK, &in.set, &out.set) == -1) return -1;
+ return out.mask;
}
-