All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 0s
32 lines
1010 B
Bash
32 lines
1010 B
Bash
#!/bin/bash
|
|
|
|
(
|
|
# Даем сессии 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 gitstatusd | 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' |