From 6eb2801cbaada9c5b6403fc2b450bf329f867687 Mon Sep 17 00:00:00 2001 From: hogweed1 Date: Tue, 10 Nov 2026 02:17:59 +1000 Subject: [PATCH] well, --- files/zsh/rm-orphaned-zshes.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/files/zsh/rm-orphaned-zshes.sh b/files/zsh/rm-orphaned-zshes.sh index 40c201f..a829c0b 100644 --- a/files/zsh/rm-orphaned-zshes.sh +++ b/files/zsh/rm-orphaned-zshes.sh @@ -1 +1,19 @@ -pgrep -f zsh | xargs -I {} sh -c 'if [ "$(ps -o ppid= -p {})" -eq 1 ]; then kill {}; fi' \ No newline at end of file +( + # Даем сессии 2 секунды полностью подняться в фоне + sleep 2 + CURRENT_PID=$$ + + pgrep -f zsh | while read -r pid; do + # Пропускаем себя, чтобы не убить текущую сессию + if [ "$pid" -eq "$CURRENT_PID" ]; then + continue + fi + + # Если родитель PID 1 — уничтожаем + if [ "$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d ' ')" -eq 1 ]; then + kill -9 "$pid" 2>/dev/null + fi + done +) & + +#pgrep -f zsh | xargs -I {} sh -c 'if [ "$(ps -o ppid= -p {})" -eq 1 ]; then kill {}; fi' \ No newline at end of file