| 5751 | } |
| 5752 | |
| 5753 | static void sigShutdownHandler(int sig) { |
| 5754 | char *msg; |
| 5755 | |
| 5756 | switch (sig) { |
| 5757 | case SIGINT: |
| 5758 | msg = "Received SIGINT scheduling shutdown..."; |
| 5759 | break; |
| 5760 | case SIGTERM: |
| 5761 | msg = "Received SIGTERM scheduling shutdown..."; |
| 5762 | break; |
| 5763 | default: |
| 5764 | msg = "Received shutdown signal, scheduling shutdown..."; |
| 5765 | }; |
| 5766 | |
| 5767 | /* SIGINT is often delivered via Ctrl+C in an interactive session. |
| 5768 | * If we receive the signal the second time, we interpret this as |
| 5769 | * the user really wanting to quit ASAP without waiting to persist |
| 5770 | * on disk. */ |
| 5771 | if (server.shutdown_asap && sig == SIGINT) { |
| 5772 | serverLogFromHandler(LL_WARNING, "You insist... exiting now."); |
| 5773 | rdbRemoveTempFile(getpid(), 1); |
| 5774 | exit(1); /* Exit with an error since this was not a clean shutdown. */ |
| 5775 | } else if (server.loading) { |
| 5776 | serverLogFromHandler(LL_WARNING, "Received shutdown signal during loading, exiting now."); |
| 5777 | exit(0); |
| 5778 | } |
| 5779 | |
| 5780 | serverLogFromHandler(LL_WARNING, msg); |
| 5781 | server.shutdown_asap = 1; |
| 5782 | } |
| 5783 | |
| 5784 | void setupSignalHandlers(void) { |
| 5785 | struct sigaction act; |
nothing calls this directly
no test coverage detected