github.com/pingcap/tiflow@v0.0.0-20240520035814-5bf52d54e205/tests/integration_tests/_utils/cleanup_process (about)

     1  #!/bin/bash
     2  # parameter 1: process name
     3  
     4  process=$1
     5  retry_count=20
     6  
     7  killall $process || true
     8  
     9  counter=0
    10  while [ $counter -lt $retry_count ]; do
    11  	pgrep -x $process >/dev/null 2>&1
    12  	ret=$?
    13  	if [ "$ret" != "0" ]; then
    14  		echo "process $process already exit"
    15  		exit 0
    16  	fi
    17  	((counter += 1))
    18  	sleep 0.5
    19  	killall $process || true
    20  	echo "wait process $process exit for $counter-th time..."
    21  done
    22  
    23  echo "wait process $process exit timeout"
    24  exit 1