File: sigprocmask.c

package info (click to toggle)
valgrind 1%3A3.12.0~svn20160714-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 120,428 kB
  • ctags: 70,855
  • sloc: ansic: 674,645; exp: 26,134; xml: 21,574; asm: 7,570; cpp: 7,567; makefile: 7,380; sh: 6,188; perl: 5,855; haskell: 195
file content (66 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66

#include <signal.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>

// Reg test for bug #93328: we were using too-big sigset types, and thus
// trashing memory when we wrote out the 'oldset' param from sigprocmask().

int main(void)
{
#if defined(__NR_sigprocmask)        \
    && !defined(__powerpc64__)       \
    && !defined(__s390x__)           \
    && !defined(__arm__)

   // arm-linux uses rt_sigprocmask, so no sigset mangling takes place

   int x[6], *s, *os, i;

   x[0] = 0x11111111;
   x[1] = 0x89abcdef;
   x[2] = 0x22222222;
   x[3] = 0x33333333;
   x[4] = 0x0;
   x[5] = 0x44444444;

   s  = &x[1];
   os = &x[4];

   // Make sure the system is in a known state with no signals
   // blocked as perl has been known to leave some signals blocked
   // when starting child processes which can cause failures in
   // this test unless we reset things here.
   syscall(__NR_sigprocmask, SIG_SETMASK, os, NULL);

   fprintf(stderr, "before\n");
   for (i = 0; i < 6; i++) {
      fprintf(stderr, "%x ", x[i]);
   }
   fprintf(stderr, "\n");

   syscall(__NR_sigprocmask, SIG_BLOCK, s, os);

   fprintf(stderr, "after1\n");
   for (i = 0; i < 6; i++) {
      fprintf(stderr, "%x ", x[i]);
   }
   fprintf(stderr, "\n");
   
   syscall(__NR_sigprocmask, SIG_BLOCK, s, os);

   fprintf(stderr, "after2\n");
   for (i = 0; i < 6; i++) {
      fprintf(stderr, "%x ", x[i]);
   }
   fprintf(stderr, "\n");

#else

   fprintf(stderr, "__NR_sigprocmask not supported on this platform\n");

#endif

   return(0);
}