blob: 550c7b9477891eef1bdadbe3d10843823748a6da [file] [log] [blame]
#!/usr/bin/env bash
cmd=$1
force_foreground=$2
shift
shift
if [[ "$force_foreground" == "1" ]]
then
setsid $cmd $force_foreground $*
else
setsid $cmd $force_foreground $* &
pid=$!
trap "echo setsid_wrapper.sh: got signal, killing child pid ${pid}; kill ${pid}; sleep .1;" SIGINT SIGTERM
wait ${pid}
exit $?
fi