Fix absolute path for build directory
[anna.git] / example / diameter / launcher / deployments / aots / agents / ADML / stop.sh
1 #!/bin/bash
2 function pgrep_live {
3   pids=$(pgrep "$1");
4   [ "$pids" ] || return;
5   ps -o s= -o pid= $pids | sed -n 's/^[^ZT][[:space:]]\+//p';
6 }
7 cd `dirname $0`
8 PID=$(pgrep_live ^ADML)
9 [ -z "$PID" ] && exit 0
10 kill $PID
11
12 # Protection to force kill (with SIGKILL) if ADML still alive after certain time:
13 seconds2force=3
14 count=$((10*seconds2force))
15 kill0=0
16 while [ $kill0 -eq 0 -a $count -gt 0 ]
17 do
18   sleep 0.1
19   count=$((count-1))
20   kill -0 $PID 2>/dev/null
21   kill0=$?
22   echo -n .
23 done
24 [ $kill0 -eq 0 ] && { echo " sigkill to ADML pid $PID !" ; kill -9 $PID ; }
25 rm -f .pid
26