Commit 81f5c328 authored by nextime's avatar nextime

Fix init scripts to kill processes even without PID file

- Stop functions now kill daemon processes regardless of PID file existence
- Added fallback pkill mechanism for processes without PID files
- Uses graceful TERM signal followed by force KILL signal
- Fixed both wssshd and wssshc init scripts
- Ensures complete process cleanup in all scenarios
parent 9c51519e
......@@ -186,9 +186,9 @@ stop() {
sleep 2
fi
# Now check if the daemon is still running and stop it directly if needed
# Check if daemon is running via PID file
if is_running; then
echo "Stopping daemon directly..."
echo "Stopping daemon via PID file..."
local pid=$(cat "$PIDFILE")
# Try to stop gracefully first
kill -TERM "$pid" 2>/dev/null
......@@ -200,11 +200,14 @@ stop() {
kill -KILL "$pid" 2>/dev/null
sleep 1
fi
# Also kill any other wssshc processes that might be running
pkill -f "^/usr/bin/wssshc" 2>/dev/null || true
fi
# Also kill any wssshc processes that might be running (regardless of PID file)
echo "Ensuring all wssshc processes are stopped..."
pkill -TERM -f "^/usr/bin/wssshc" 2>/dev/null || true
sleep 2
pkill -KILL -f "^/usr/bin/wssshc" 2>/dev/null || true
# Clean up PID files
rm -f "$PIDFILE" "$WATCHDOG_PIDFILE"
......
......@@ -129,9 +129,9 @@ stop() {
sleep 2
fi
# Now check if the daemon is still running and stop it directly if needed
# Check if daemon is running via PID file
if is_running; then
echo "Stopping daemon directly..."
echo "Stopping daemon via PID file..."
local pid=$(cat "$PIDFILE")
# Try to stop gracefully first
kill -TERM "$pid" 2>/dev/null
......@@ -143,11 +143,14 @@ stop() {
kill -KILL "$pid" 2>/dev/null
sleep 1
fi
# Also kill any other wssshd processes that might be running
pkill -f "^/usr/bin/wssshd" 2>/dev/null || true
fi
# Also kill any wssshd processes that might be running (regardless of PID file)
echo "Ensuring all wssshd processes are stopped..."
pkill -TERM -f "^/usr/bin/wssshd" 2>/dev/null || true
sleep 2
pkill -KILL -f "^/usr/bin/wssshd" 2>/dev/null || true
# Clean up PID files
rm -f "$PIDFILE" "$WATCHDOG_PIDFILE"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment