From f23745d18b2ab954d4e4def50109e73146c18d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Sat, 29 Aug 2026 21:01:02 -0300 Subject: [PATCH] fix(remoteshell): wait for the ssh daemon to end before a new one starts A kill only asks the kernel to end a process, so it returns before the process is gone. The fallback started a new daemon on the next line, which could find the port still held by the old one, fail to start, and leave the node with no daemon at all. Wait for the processes to end, for up to ten seconds, before the new daemon starts. The test that a process is still there sends no signal. --- xCAT/postscripts/remoteshell | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/xCAT/postscripts/remoteshell b/xCAT/postscripts/remoteshell index 54390fd93..3378b9253 100755 --- a/xCAT/postscripts/remoteshell +++ b/xCAT/postscripts/remoteshell @@ -648,7 +648,19 @@ fi #try to kill the process and start if [ "$?" != "0" ];then PIDLIST=`ps aux | grep -v grep | grep "/usr/sbin/sshd"|awk -F" " '{print $2}'|xargs` - [ -n "$PIDLIST" ] && kill -9 $PIDLIST + if [ -n "$PIDLIST" ]; then + kill -9 $PIDLIST + waited=0 + while [ $waited -lt 10 ]; do + alive=0 + for pid in $PIDLIST; do + if kill -0 $pid 2>/dev/null; then alive=1; fi + done + if [ $alive -eq 0 ]; then break; fi + sleep 1 + waited=`expr $waited + 1` + done + fi /usr/sbin/sshd fi kill -9 $CREDPID