mirror of
https://github.com/yuaotian/go-cursor-help.git
synced 2025-06-08 04:22:06 +08:00
Fix process detection in Linux script to avoid terminating itself
This commit is contained in:
parent
6d53a926e0
commit
4daa24e80a
@ -164,12 +164,12 @@ check_and_kill_cursor() {
|
|||||||
get_process_details() {
|
get_process_details() {
|
||||||
local process_name="$1"
|
local process_name="$1"
|
||||||
log_debug "正在获取 $process_name 进程详细信息:"
|
log_debug "正在获取 $process_name 进程详细信息:"
|
||||||
ps aux | grep -i "cursor" | grep -v grep
|
ps aux | grep -i "cursor" | grep -v grep | grep -v "cursor_linux_id_modifier.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
while [ $attempt -le $max_attempts ]; do
|
||||||
# 使用更精确的匹配来获取 Cursor 进程
|
# 使用更精确的匹配来获取 Cursor 进程,排除当前脚本和grep进程
|
||||||
CURSOR_PIDS=$(pgrep -f "cursor" || true)
|
CURSOR_PIDS=$(ps aux | grep -i "cursor" | grep -v "grep" | grep -v "cursor_linux_id_modifier.sh" | awk '{print $2}' || true)
|
||||||
|
|
||||||
if [ -z "$CURSOR_PIDS" ]; then
|
if [ -z "$CURSOR_PIDS" ]; then
|
||||||
log_info "未发现运行中的 Cursor 进程"
|
log_info "未发现运行中的 Cursor 进程"
|
||||||
@ -190,8 +190,8 @@ check_and_kill_cursor() {
|
|||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
# 再次检查进程是否还在运行
|
# 再次检查进程是否还在运行,排除当前脚本和grep进程
|
||||||
if ! pgrep -f "cursor" > /dev/null; then
|
if ! ps aux | grep -i "cursor" | grep -v "grep" | grep -v "cursor_linux_id_modifier.sh" > /dev/null; then
|
||||||
log_info "Cursor 进程已成功关闭"
|
log_info "Cursor 进程已成功关闭"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user