Browse Source

luci-app-ssr-plus: fix kill subprocesses

Signed-off-by: Tianling Shen <[email protected]>
Tianling Shen 3 years ago
parent
commit
8960a920d4
1 changed files with 7 additions and 1 deletions
  1. 7 1
      luci-app-ssr-plus/root/etc/init.d/shadowsocksr

+ 7 - 1
luci-app-ssr-plus/root/etc/init.d/shadowsocksr

@@ -868,7 +868,13 @@ stop() {
 	fi
 	$PS -w | grep -v "grep" | grep ssr-monitor | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
 	$PS -w | grep -v "grep" | grep "sleep 0000" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
-	$PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 &
+	( \
+		# Graceful kill first, so programs have the chance to stop its subprocesses
+		$PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill >/dev/null 2>&1 ; \
+		sleep 3s; \
+		# Force kill hanged programs
+		$PS -w | grep -v "grep" | grep "$TMP_PATH" | awk '{print $1}' | xargs kill -9 >/dev/null 2>&1 ; \
+	)
 	killall -q -9 v2ray-plugin obfs-local xray-plugin
 	rm -f /var/lock/ssr-monitor.lock
 	if [ -f "/tmp/dnsmasq.d/dnsmasq-ssrplus.conf" ]; then