[OpenWrt-Devel] [PATCH procd 5/8] Kill processes on shutdown

Michel Stam m.stam at fugro.nl
Thu Oct 2 08:56:20 EDT 2014


Procd as it currently is does not kill the running processes during shutdown.
As this might cause undesired behaviour, this should be implemented.
Implementation was taken from busybox 1.19.4

Signed-off-by: Michel Stam <m.stam at fugro.nl>
---
 state.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/state.c b/state.c
index 2de32e1..05f7dc5 100644
--- a/state.c
+++ b/state.c
@@ -15,6 +15,8 @@
 #include <sys/reboot.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <signal.h>
 
 #include "procd.h"
 #include "syslog.h"
@@ -75,6 +77,14 @@ static void state_enter(void)
 		break;
 
 	case STATE_HALT:
+		LOG("- SIGTERM processes -\n");
+		kill(-1, SIGTERM);
+		sync();
+		sleep(1);
+		LOG("- SIGKILL processes -\n");
+		kill(-1, SIGKILL);
+		sync();
+		sleep(1);
 		LOG("- reboot -\n");
 		reboot(reboot_event);
 		break;
-- 
1.7.12.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list