1 /* Refer https://bugs.kde.org/show_bug.cgi?id=234814 2 */ 3 4 #include <stdio.h> 5 #include <signal.h> 6 #include <unistd.h> 7 8 const char kSigbus[] = "I caught the SIGBUS signal!\n"; 9 10 int GLOB = 3; 11 12 void mysigbus() { 13 write(1, kSigbus, sizeof(kSigbus)-1); 14 GLOB--; 15 return; 16 } 17 18 int main() { 19 struct sigaction sa; 20 sa.sa_handler = mysigbus; 21 sigemptyset(&sa.sa_mask); 22 sa.sa_flags = 0; 23 if (sigaction(SIGBUS, &sa, NULL) == -1) { 24 perror("ERROR:"); 25 } 26 while(GLOB) { 27 kill(getpid(), SIGBUS); 28 }; 29 return 0; 30 } 31 32