| 449 | } |
| 450 | |
| 451 | void SetTrapHandler() { |
| 452 | const int signals[] = { |
| 453 | SIGSEGV, SIGBUS, SIGILL, SIGFPE, SIGABRT, |
| 454 | // SIGUSR1 is special in that it is triggered by user and does not abort |
| 455 | SIGUSR1, |
| 456 | }; |
| 457 | |
| 458 | const int ignored_signals[] = { |
| 459 | SIGPIPE, |
| 460 | }; |
| 461 | |
| 462 | struct sigaction sigact; |
| 463 | size_t i; |
| 464 | |
| 465 | unlink(P_tmpdir "/bessd_crash.log"); |
| 466 | |
| 467 | sigact.sa_sigaction = TrapHandler; |
| 468 | sigact.sa_flags = SA_RESTART | SA_SIGINFO; |
| 469 | |
| 470 | for (i = 0; i < sizeof(signals) / sizeof(int); i++) { |
| 471 | int ret = sigaction(signals[i], &sigact, nullptr); |
| 472 | DCHECK_NE(ret, 1); |
| 473 | } |
| 474 | |
| 475 | for (i = 0; i < sizeof(ignored_signals) / sizeof(int); i++) { |
| 476 | signal(ignored_signals[i], SIG_IGN); |
| 477 | } |
| 478 | } |
| 479 | |
| 480 | template <typename T> |
| 481 | static void DumpType() { |