#include #include #include #include int is_blocked(int sig) { sigset_t set; sigprocmask(SIG_BLOCK, NULL, &set); return sigismember(&set, sig); } void *eip(struct ucontext *context) { return (void *)context->uc_mcontext.gregs[14]; } void sig_1(int sig, siginfo_t *info, struct ucontext *context) { printf("%d %d\n", sig, is_blocked(2)); printf("eip: %x\n", eip(context)); } void sig_2(int sig, siginfo_t *info, struct ucontext *context) { printf("%d %d\n", sig, is_blocked(1)); printf("eip: %x\n", eip(context)); } int tkill(int tid, int sig) { syscall(SYS_tkill, tid, sig); } int main(void) { sigset_t set; struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sa.sa_sigaction = sig_1; sigaction(1, &sa, 0); sa.sa_sigaction = sig_2; sigaction(2, &sa, 0); sigemptyset(&set); sigaddset(&set, 1); sigaddset(&set, 2); printf("sig_1=%x\n", sig_1); printf("sig_2=%x\n", sig_2); sigprocmask(SIG_BLOCK, &set, NULL); kill(getpid(), 1); kill(getpid(), 2); sigprocmask(SIG_UNBLOCK, &set, NULL); return 0; }