mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-12 10:31:26 +02:00
Improved pid detection
This commit is contained in:
@@ -59,9 +59,13 @@ if [ "$$" -eq 1 ]; then
|
|||||||
echo "Termination signal received, forwarding to subprocesses..."
|
echo "Termination signal received, forwarding to subprocesses..."
|
||||||
|
|
||||||
# Gracefully terminate open subprocesses
|
# Gracefully terminate open subprocesses
|
||||||
for pid in $(grep -l "/etc/cont-init.d" /proc/*/cmdline 2>/dev/null | grep -oP '/proc/\K[0-9]+'); do
|
for pid in /proc/[0-9]*/; do
|
||||||
echo "Terminating PID $pid"
|
pid=${pid#/proc/}
|
||||||
kill -TERM "$pid" 2>/dev/null || true
|
pid=${pid%/}
|
||||||
|
if [[ "$pid" -ne 1 ]]; then
|
||||||
|
echo "Terminating PID $pid"
|
||||||
|
kill -TERM "$pid" 2>/dev/null || echo "Failed to terminate PID $pid"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Wait for all child processes to terminate
|
# Wait for all child processes to terminate
|
||||||
|
|||||||
Reference in New Issue
Block a user