sigprocmask.c revision 89c33d29d64cab44cbd67d7b160c285a8ad6b202
1
2#include <signal.h>
3#include <stdio.h>
4#include <sys/syscall.h>
5#include <unistd.h>
6
7// Reg test for bug #93328: we were using too-big sigset types, and thus
8// trashing memory when we wrote out the 'oldset' param from sigprocmask().
9
10int main(void)
11{
12   int x[6], *s, *os, i;
13
14   x[0] = 0x11111111;
15   x[1] = 0x89abcdef;
16   x[2] = 0x22222222;
17   x[3] = 0x33333333;
18   x[4] = 0x0;
19   x[5] = 0x44444444;
20
21   s  = &x[1];
22   os = &x[4];
23
24   // Make sure the system is in a known state with no signals
25   // blocked as perl has been known to leave some signals blocked
26   // when starting child processes which can cause failures in
27   // this test unless we reset things here.
28   syscall(__NR_sigprocmask, SIG_SETMASK, os, NULL);
29
30   fprintf(stderr, "before\n");
31   for (i = 0; i < 6; i++) {
32      fprintf(stderr, "%x ", x[i]);
33   }
34   fprintf(stderr, "\n");
35
36   syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
37
38   fprintf(stderr, "after1\n");
39   for (i = 0; i < 6; i++) {
40      fprintf(stderr, "%x ", x[i]);
41   }
42   fprintf(stderr, "\n");
43
44   syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
45
46   fprintf(stderr, "after2\n");
47   for (i = 0; i < 6; i++) {
48      fprintf(stderr, "%x ", x[i]);
49   }
50   fprintf(stderr, "\n");
51
52   return(0);
53}
54