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