github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/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      echo "wait process $process exit for $counter-th time..."
    20  done
    21  
    22  echo "wait process $process exit timeout"
    23  exit 1