We handle SIGTERM on the daemon, by closing the socket opened for that
connection.

Signed-off-by: Janani Venkataraman <janan...@linux.vnet.ibm.com>
---
 src/coredump.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/coredump.c b/src/coredump.c
index 72ba8d8..c0da457 100755
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -562,6 +562,17 @@ int handle_request(void)
        return 0;
 }
 
+/* Handles Signals to the Daemon */
+void sig_daemon_handler(int sig)
+{
+       close(socket_fd);
+       unlink(SOCKET_PATH);
+
+       gencore_log("[%d]: Cleanup done and daemon exiting.\n", pid_log);
+
+       fclose(fp_log);
+}
+
 /* Daemon for self dump */
 int daemon_dump(void)
 {
@@ -602,6 +613,11 @@ int daemon_dump(void)
        /* SIGCHILD - Signal handler */
        signal(SIGCHLD, sigchild_handler);
 
+       /* Terminate Daemon - signal handler */
+       signal(SIGTERM, sig_daemon_handler);
+       signal(SIGSEGV, sig_daemon_handler);
+       signal(SIGPIPE, sig_daemon_handler);
+
        while (1) {
 
                /* Blocks on request */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to