These can be used to manage starting and stopping processes that spawn children that otherwise would not be terminated when the moonlight session ends
33 lines
528 B
Bash
Executable File
33 lines
528 B
Bash
Executable File
#!/usr/bin/env bash
|
|
###
|
|
# File: sunshine-run
|
|
# Project: bin
|
|
# File Created: Tuesday, 23rd August 2023 3:28:52 pm
|
|
# Author: Josh.5 (jsunnex@gmail.com)
|
|
# -----
|
|
# Last Modified: Friday, 23rd August 2023 4:21:00 pm
|
|
# Modified By: Josh.5 (jsunnex@gmail.com)
|
|
###
|
|
set -e
|
|
|
|
# CATCH TERM SIGNAL:
|
|
_term() {
|
|
pkill -P $$
|
|
}
|
|
for sig in INT QUIT HUP TERM; do
|
|
trap "
|
|
_term
|
|
trap - $sig EXIT
|
|
kill -s $sig "'"$$"' "$sig"
|
|
done
|
|
trap _term EXIT
|
|
|
|
|
|
# RUN CHILD PROCESS
|
|
"${@}" &
|
|
proc_pid=$!
|
|
|
|
|
|
# WAIT FOR CHILD PROCESS:
|
|
wait "$proc_pid"
|