Linux: running 2 processes by one command and exiting both after one exited

This is an example to run sublime text and terminal with one script. Terminal will be closed when ST is closed.


cd "${HOME}/.local/Sublime Text 2"
./sublime_text & st_pid=$!
urxvt -name borderless_urxvt & rxvt_pid=$!

onExit() {
    echo Exiting
    kill -15 $rxvt_pid 2>/dev/null
    kill -15 $st_pid 2>/dev/null
    echo All prcesses stopped

trap "onExit" KILL HUP INT TERM

wait $st_pid ;