From ea284040ffcaa8cd1c52e597c87b336524adeb8c Mon Sep 17 00:00:00 2001 From: Zhang Sheng Date: Mon, 19 Aug 2024 10:45:35 +0800 Subject: [PATCH] fix: Upgrading the existence of coredump messages SIGTERM to dde-grand-search-daemon use `preinstall` script Log: as title Bug: https://pms.uniontech.com/bug-view-268325.html --- debian/dde-grand-search.preinst | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 debian/dde-grand-search.preinst diff --git a/debian/dde-grand-search.preinst b/debian/dde-grand-search.preinst new file mode 100755 index 00000000..90879d2c --- /dev/null +++ b/debian/dde-grand-search.preinst @@ -0,0 +1,28 @@ +#!/bin/bash + +# 进程名称 +PROCESS_NAME="dde-grand-search-daemon" + +# 获取进程ID +PID=$(pgrep -f "$PROCESS_NAME") + +if [ -z "$PID" ]; then + echo "Process $PROCESS_NAME is not running." + exit 0 +fi + +echo "Process $PROCESS_NAME (PID: $PID) found. Attempting to terminate..." + +# 发送 SIGTERM 信号 +kill -TERM "$PID" +sleep 2 # 等待进程响应 SIGTERM + +# 再次检查进程是否仍在运行 +if pgrep -f "$PROCESS_NAME" > /dev/null; then + echo "Process did not terminate. Sending SIGKILL..." + # 发送 SIGKILL 信号 + kill -KILL "$PID" + echo "Process $PROCESS_NAME has been killed." +else + echo "Process $PROCESS_NAME terminated successfully." +fi