[PATCH 24/33] Handling SIG TERM of the child

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We handle SIGTERM on the child, by sending a message to the client and then
closing the socket opened for that connection.

Signed-off-by: Janani Venkataraman <jananive@xxxxxxxxxxxxxxxxxx>
---
 src/coredump.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/coredump.c b/src/coredump.c
index c0da457..ab120b9 100755
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -501,6 +501,18 @@ int dump_task(struct ucred *client_info, char *core_file)
 	return 0;
 }
 
+/* Handles signals to the child */
+void sig_handler_service_proc(int sig)
+{
+	if (sig != SIGPIPE)
+		send_reply(EINTR);
+	close(new_sock);
+
+	gencore_log("[%d]: Cleanup done and child exiting.\n", pid_log);
+
+	fflush(fp_log);
+}
+
 /* Services requests */
 int service_request(void)
 {
@@ -508,6 +520,11 @@ int service_request(void)
 	char core_file[CORE_FILE_NAME_SZ];
 	struct ucred client_info;
 
+	/* Handles stopping of the servicing process */
+	signal(SIGTERM, sig_handler_service_proc);
+	signal(SIGSEGV, sig_handler_service_proc);
+	signal(SIGPIPE, sig_handler_service_proc);
+
 	/* Receive the message */
 	ret = receive_core_filename(core_file);
 	if (ret)

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux