blob: 030c3b079de730b6ef1efcdd227b868ba7a248c9 [file] [log] [blame]
Klement Sekeradb4e84c2017-08-11 10:06:15 +02001#!/bin/bash
2
Klement Sekerab23ffd72021-05-31 16:08:53 +02003cmd=$1
4force_foreground=$2
5shift
6shift
7
8if [[ "$force_foreground" == "1" ]]
Klement Sekeradb4e84c2017-08-11 10:06:15 +02009then
Klement Sekerab23ffd72021-05-31 16:08:53 +020010 setsid $cmd $force_foreground $*
Klement Sekeradb4e84c2017-08-11 10:06:15 +020011else
Klement Sekerab23ffd72021-05-31 16:08:53 +020012 setsid $cmd $force_foreground $* &
Klement Sekeradb4e84c2017-08-11 10:06:15 +020013 pid=$!
14 trap "echo setsid_wrapper.sh: got signal, killing child pid ${pid}; kill ${pid}; sleep .1;" SIGINT SIGTERM
Klement Sekera8712ada2017-08-16 16:38:10 +020015 wait ${pid}
16 exit $?
Klement Sekeradb4e84c2017-08-11 10:06:15 +020017fi