Tag: 后缀

SIGSEGV处理程序中的Segfault

让我们假设我有以下C代码: static void handler(int sig, siginfo_t *si, void *unused) { printf(“BOOM!\n”); //another segfault here exit(-1); } int main(int argc, char *argv[]) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sigemptyset(&sa.sa_mask); sa.sa_sigaction = handler; if (sigaction(SIGSEGV, &sa, NULL) == -1) perror(“failed to set handler”); // call other stuff here, somewhere in the callstack a segfault happens } […]