jvpp: ignore messages if callback method is missing (VPP-548)
[vpp.git] / test / scripts / run_in_venv_with_cleanup.sh
1 #!/bin/bash
2
3 rv=0
4
5 atexit() {
6         group_id=`ps -p $$ -o pgid=`
7         my_id=$$
8         ids=`pgrep -g $group_id -d ' ' | sed "s/\b$my_id\b//g"`
9         echo "Killing possible remaining process IDs: $ids"
10         for id in $ids
11         do
12                 if ps -p $id > /dev/null
13                 then
14                         kill -9 $id
15                 fi
16         done
17         exit $rv
18 }
19
20 trap "atexit;" SIGINT SIGTERM
21
22 FORCE_FOREGROUND=$1
23 shift
24
25 source $1
26 shift
27
28 if [[ "${FORCE_FOREGROUND}" == "1" ]]
29 then
30         $*
31 else
32         $* &
33         wait
34 fi
35
36 rv=$?
37 atexit
38 exit $rv