From accab5dd878337cd4faea343ace6466bcdf1a37f Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Wed, 29 Dec 2021 06:07:28 +0100 Subject: [PATCH] fix: Add more reliable method of killing stale processes --- infect.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/infect.sh b/infect.sh index c0295fa..91c8196 100755 --- a/infect.sh +++ b/infect.sh @@ -91,7 +91,13 @@ echo '#!/bin/ash rm third_stage.sh # kill all remaining processes -lsof | grep old_root | awk "{print \$1}" | uniq | xargs kill -9 2>/dev/null +cd /proc +ps ax | awk "{print \$1}" | tail -n +3 | while read pid; do + if grep -qE "^/dev/\w+ / " /proc/$pid/mounts; then + kill -9 $pid + fi +done +cd / /bin/umount -Rl old_root/* 2>/dev/null /bin/umount old_root