Home | History | Annotate | Download | only in tests
      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 
     10 int main(void)
     11 {
     12 #if defined(__NR_sigprocmask)        \
     13     && !defined(__powerpc64__)       \
     14     && !defined(__s390x__)           \
     15     && !defined(__arm__)
     16 
     17    // arm-linux uses rt_sigprocmask, so no sigset mangling takes place
     18 
     19    int x[6], *s, *os, i;
     20 
     21    x[0] = 0x11111111;
     22    x[1] = 0x89abcdef;
     23    x[2] = 0x22222222;
     24    x[3] = 0x33333333;
     25    x[4] = 0x0;
     26    x[5] = 0x44444444;
     27 
     28    s  = &x[1];
     29    os = &x[4];
     30 
     31    // Make sure the system is in a known state with no signals
     32    // blocked as perl has been known to leave some signals blocked
     33    // when starting child processes which can cause failures in
     34    // this test unless we reset things here.
     35    syscall(__NR_sigprocmask, SIG_SETMASK, os, NULL);
     36 
     37    fprintf(stderr, "before\n");
     38    for (i = 0; i < 6; i++) {
     39       fprintf(stderr, "%x ", x[i]);
     40    }
     41    fprintf(stderr, "\n");
     42 
     43    syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
     44 
     45    fprintf(stderr, "after1\n");
     46    for (i = 0; i < 6; i++) {
     47       fprintf(stderr, "%x ", x[i]);
     48    }
     49    fprintf(stderr, "\n");
     50 
     51    syscall(__NR_sigprocmask, SIG_BLOCK, s, os);
     52 
     53    fprintf(stderr, "after2\n");
     54    for (i = 0; i < 6; i++) {
     55       fprintf(stderr, "%x ", x[i]);
     56    }
     57    fprintf(stderr, "\n");
     58 
     59 #else
     60 
     61    fprintf(stderr, "__NR_sigprocmask not supported on this platform\n");
     62 
     63 #endif
     64 
     65    return(0);
     66 }
     67