nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 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 | { |
tom | 42d6367 | 2005-11-02 15:46:07 +0000 | [diff] [blame^] | 12 | int x[6], *s, *os, i; |
sewardj | 1c39800 | 2005-03-23 13:09:55 +0000 | [diff] [blame] | 13 | |
sewardj | 1c39800 | 2005-03-23 13:09:55 +0000 | [diff] [blame] | 14 | #ifdef __NR_sigprocmask |
nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 15 | |
| 16 | x[0] = 0x11111111; |
| 17 | x[1] = 0x89abcdef; |
| 18 | x[2] = 0x22222222; |
| 19 | x[3] = 0x33333333; |
| 20 | x[4] = 0x0; |
| 21 | x[5] = 0x44444444; |
| 22 | |
| 23 | s = &x[1]; |
| 24 | os = &x[4]; |
| 25 | |
thughes | 89c33d2 | 2004-11-16 12:09:43 +0000 | [diff] [blame] | 26 | // Make sure the system is in a known state with no signals |
| 27 | // blocked as perl has been known to leave some signals blocked |
| 28 | // when starting child processes which can cause failures in |
| 29 | // this test unless we reset things here. |
tom | 42d6367 | 2005-11-02 15:46:07 +0000 | [diff] [blame^] | 30 | syscall(__NR_sigprocmask, SIG_SETMASK, os, NULL); |
thughes | 89c33d2 | 2004-11-16 12:09:43 +0000 | [diff] [blame] | 31 | |
nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 32 | fprintf(stderr, "before\n"); |
| 33 | for (i = 0; i < 6; i++) { |
| 34 | fprintf(stderr, "%x ", x[i]); |
| 35 | } |
| 36 | fprintf(stderr, "\n"); |
| 37 | |
tom | 42d6367 | 2005-11-02 15:46:07 +0000 | [diff] [blame^] | 38 | syscall(__NR_sigprocmask, SIG_BLOCK, s, os); |
nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 39 | |
| 40 | fprintf(stderr, "after1\n"); |
| 41 | for (i = 0; i < 6; i++) { |
| 42 | fprintf(stderr, "%x ", x[i]); |
| 43 | } |
| 44 | fprintf(stderr, "\n"); |
| 45 | |
tom | 42d6367 | 2005-11-02 15:46:07 +0000 | [diff] [blame^] | 46 | syscall(__NR_sigprocmask, SIG_BLOCK, s, os); |
nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 47 | |
| 48 | fprintf(stderr, "after2\n"); |
| 49 | for (i = 0; i < 6; i++) { |
| 50 | fprintf(stderr, "%x ", x[i]); |
| 51 | } |
| 52 | fprintf(stderr, "\n"); |
tom | 42d6367 | 2005-11-02 15:46:07 +0000 | [diff] [blame^] | 53 | |
| 54 | #else |
| 55 | |
| 56 | fprintf(stderr, "__NR_sigprocmask not supported on this platform\n"); |
| 57 | |
| 58 | #endif |
| 59 | |
nethercote | 7fbe08a | 2004-11-15 19:03:27 +0000 | [diff] [blame] | 60 | return(0); |
| 61 | } |