From 0f9d42a4e5cdeab684f43bdf9d01dbdfa27ec514 Mon Sep 17 00:00:00 2001 From: tw-kang Date: Wed, 28 Feb 2024 18:47:39 +0900 Subject: [PATCH 1/5] [CUBRIDQA-1214] Update xkill http://jira.cubrid.org/browse/CUBRIDQA-1214 --- CTP/shell/init_path/init.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 2bb9dc3e..82f762d7 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -1071,7 +1071,7 @@ function xkill if [ "$OS" == Windows_NT ] then win_svr_pid=`get_win_service_pid` - for pid in `ps -W | grep "${strkill}" | awk '{print $1}'` + for pid in `ps -W | grep -w "${strkill}" | awk '{print $1}'` do is_in_white_list=0 for svr_id in ${win_svr_pid} @@ -1088,9 +1088,9 @@ function xkill else if [ $fullCommand -eq 1 ] then - pids=`ps -u $USER -o pid,command | grep "$strkill" | grep -v grep | awk '{print $1}'` + pids=`ps -u $USER -o pid,command | grep -w "$strkill" | grep -v grep | awk '{print $1}'` else - pids=`ps -u $USER -o pid,comm | grep "$strkill" | grep -v grep | awk '{print $1}'` + pids=`ps -u $USER -o pid,comm | grep -w "$strkill" | grep -v grep | awk '{print $1}'` fi for pid in $pids From 029f4aa4b76aa106c0d898c66a37f695ee23c21a Mon Sep 17 00:00:00 2001 From: tw-kang Date: Thu, 29 Feb 2024 16:23:17 +0900 Subject: [PATCH 2/5] Revert "[CUBRIDQA-1214] Update xkill" This reverts commit 0f9d42a4e5cdeab684f43bdf9d01dbdfa27ec514. --- CTP/shell/init_path/init.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 82f762d7..2bb9dc3e 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -1071,7 +1071,7 @@ function xkill if [ "$OS" == Windows_NT ] then win_svr_pid=`get_win_service_pid` - for pid in `ps -W | grep -w "${strkill}" | awk '{print $1}'` + for pid in `ps -W | grep "${strkill}" | awk '{print $1}'` do is_in_white_list=0 for svr_id in ${win_svr_pid} @@ -1088,9 +1088,9 @@ function xkill else if [ $fullCommand -eq 1 ] then - pids=`ps -u $USER -o pid,command | grep -w "$strkill" | grep -v grep | awk '{print $1}'` + pids=`ps -u $USER -o pid,command | grep "$strkill" | grep -v grep | awk '{print $1}'` else - pids=`ps -u $USER -o pid,comm | grep -w "$strkill" | grep -v grep | awk '{print $1}'` + pids=`ps -u $USER -o pid,comm | grep "$strkill" | grep -v grep | awk '{print $1}'` fi for pid in $pids From 00a93c179d00479d86550b93e5ee56e0203ba4bf Mon Sep 17 00:00:00 2001 From: tw-kang Date: Thu, 28 Mar 2024 20:10:15 +0900 Subject: [PATCH 3/5] reinforce white list for test environment stability --- CTP/shell/init_path/init.sh | 38 +++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 2bb9dc3e..8c0cd34c 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -1070,21 +1070,8 @@ function xkill if [ "$OS" == Windows_NT ] then - win_svr_pid=`get_win_service_pid` - for pid in `ps -W | grep "${strkill}" | awk '{print $1}'` - do - is_in_white_list=0 - for svr_id in ${win_svr_pid} - do - if [ "${pid}" == "${svr_id}" ]; then - is_in_white_list=1 - break - fi - done - if [ "${is_in_white_list}" == "0" ]; then - /bin/kill -9 -f ${pid} - fi - done + win_svr_pid=$(get_win_service_pid | tr '\n' '|') + ps -W | grep "${strkill}" | awk -v win_svr_pid="${win_svr_pid}" '{ if (index(win_svr_pid, $1) == 0) print $1 }' | xargs -I {} /bin/kill -9 -f {} else if [ $fullCommand -eq 1 ] then @@ -1122,7 +1109,26 @@ function xkill_java_windows { function get_win_service_pid { - wmic PROCESS WHERE \( Name != \'wmic.exe\' and CommandLine LIKE \'%service.Server%\' \) get processid | grep -v ProcessId | sed 's/ //g' + wmic PROCESS WHERE "( + Name = 'System Idle Process' or + Name = 'System' or + Name = 'smss.exe' or + Name = 'csrss.exe' or + Name = 'wininit.exe' or + Name = 'winlogon.exe' or + Name = 'services.exe' or + Name = 'lsass.exe' or + Name = 'svchost.exe' or + Name = 'conhost.exe' or + Name = 'WmiPrvSE.exe' or + Name = 'taskhostex.exe' or + Name = 'dwm.exe' or + Name = 'rdpclip.exe' + ) or ( + CommandLine LIKE '%service.Server%' or + CommandLine LIKE '%RMIService%' or + CommandLine LIKE '%start_service%' + )" get processid | grep -v ProcessId | sed 's/ //g' } #format number like 0|123|456 From 478396c62fce25100eae9b7629b385b3873dad73 Mon Sep 17 00:00:00 2001 From: tw-kang Date: Fri, 29 Mar 2024 15:39:58 +0900 Subject: [PATCH 4/5] reflect review --- CTP/shell/init_path/init.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 8c0cd34c..51e782ee 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -1123,7 +1123,9 @@ function get_win_service_pid { Name = 'WmiPrvSE.exe' or Name = 'taskhostex.exe' or Name = 'dwm.exe' or - Name = 'rdpclip.exe' + Name = 'rdpclip.exe' or + Name = 'explorer.exe' or + Name = 'wmic.exe' ) or ( CommandLine LIKE '%service.Server%' or CommandLine LIKE '%RMIService%' or From f3fab95c641fecdf688b197fd21031594ccf72d6 Mon Sep 17 00:00:00 2001 From: tw-kang Date: Thu, 4 Apr 2024 18:04:37 +0900 Subject: [PATCH 5/5] add comment for whitelist --- CTP/shell/init_path/init.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CTP/shell/init_path/init.sh b/CTP/shell/init_path/init.sh index 51e782ee..4c6fdb77 100644 --- a/CTP/shell/init_path/init.sh +++ b/CTP/shell/init_path/init.sh @@ -1107,7 +1107,9 @@ function xkill_java_windows { } - +# This function returns whitelist. +# Whitelist includes pids for critical process that can occure system crash when it is killed. +# Also includes process for running regression test. function get_win_service_pid { wmic PROCESS WHERE "( Name = 'System Idle Process' or