030c3b079de730b6ef1efcdd227b868ba7a248c9
[vpp.git] / test / scripts / setsid_wrapper.sh
1 #!/bin/bash
2
3 cmd=$1
4 force_foreground=$2
5 shift
6 shift
7
8 if [[ "$force_foreground" == "1" ]]
9 then
10         setsid $cmd $force_foreground $*
11 else
12         setsid $cmd $force_foreground $* &
13         pid=$!
14         trap "echo setsid_wrapper.sh: got signal, killing child pid ${pid}; kill ${pid}; sleep .1;" SIGINT SIGTERM
15         wait ${pid}
16         exit $?
17 fi