Set the signal handlers to the default.
| 46 | |
| 47 | // Set the signal handlers to the default. |
| 48 | void UnhookHandler() { |
| 49 | if (already_hooked_up) { |
| 50 | struct sigaction sa; |
| 51 | // Setup the sighub handler |
| 52 | sa.sa_handler = SIG_DFL; |
| 53 | // Restart the system call, if at all possible |
| 54 | sa.sa_flags = SA_RESTART; |
| 55 | // Block every signal during the handler |
| 56 | sigfillset(&sa.sa_mask); |
| 57 | // Intercept SIGHUP and SIGINT |
| 58 | if (sigaction(SIGHUP, &sa, NULL) == -1) { |
| 59 | LOG(FATAL) << "Cannot uninstall SIGHUP handler."; |
| 60 | } |
| 61 | if (sigaction(SIGINT, &sa, NULL) == -1) { |
| 62 | LOG(FATAL) << "Cannot uninstall SIGINT handler."; |
| 63 | } |
| 64 | |
| 65 | already_hooked_up = false; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | // Return true iff a SIGINT has been received since the last time this |
| 70 | // function was called. |
no test coverage detected