• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include <signal.h>
3 #include <stdio.h>
4 #if !defined(_AIX)
5 # include <sys/syscall.h>
6 #endif
7 #include <unistd.h>
8 
9 // Reg test for bug #93328: we were using too-big sigset types, and thus
10 // trashing memory when we wrote out the 'oldset' param from sigprocmask().
11 
main(void)12 int main(void)
13 {
14 #if defined(__NR_sigprocmask)        \
15     && !defined(__powerpc64__)       \
16     && !defined(_AIX)                \
17     && !defined(__arm__)
18 
19    // arm-linux uses rt_sigprocmask, so no sigset mangling takes place
20 
21    int x[6], *s, *os, i;
22 
23    x[0] = 0x11111111;
24    x[1] = 0x89abcdef;
25    x[2] = 0x22222222;
26    x[3] = 0x33333333;
27    x[4] = 0x0;
28    x[5] = 0x44444444;
29 
30    s  = &x[1];
31    os = &x[4];
32 
33    // Make sure the system is in a known state with no signals
34    // blocked as perl has been known to leave some signals blocked
35    // when starting child processes which can cause failures in
36    // this test unless we reset things here.
37    syscall(__NR_sigprocmask, SIG_SETMASK, os, NULL);
38 
39    fprintf(stderr, "before\n");
40    for (i = 0; i < 6; i++) {
41       fprintf(stderr, "%x ", x[i]);
42    }
43    fprintf(stderr, "\n");
44 
45    syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
46 
47    fprintf(stderr, "after1\n");
48    for (i = 0; i < 6; i++) {
49       fprintf(stderr, "%x ", x[i]);
50    }
51    fprintf(stderr, "\n");
52 
53    syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
54 
55    fprintf(stderr, "after2\n");
56    for (i = 0; i < 6; i++) {
57       fprintf(stderr, "%x ", x[i]);
58    }
59    fprintf(stderr, "\n");
60 
61 #else
62 
63    fprintf(stderr, "__NR_sigprocmask not supported on this platform\n");
64 
65 #endif
66 
67    return(0);
68 }
69