Add support for running proper detached processes with sunshine-run

This allows things like Steam BP to run with sunshine-run which will auto set the resolution. And then still have sunshine-stop restore the original resolution.
This commit is contained in:
Josh.5
2023-09-11 12:29:48 +12:00
parent 771c47d602
commit aa1edd48e0

View File

@@ -30,13 +30,19 @@ else
fi fi
# Read the process PID # Read the process PID
process_pid="$(cat /tmp/sunshine-exec-run.pid)" if [ -f /tmp/sunshine-exec-run.pid ]; then
echo " - Found initial sunshine-run PID '${process_pid}'." main_process_pid="$(cat /tmp/sunshine-exec-run.pid)"
echo " - Found initial sunshine-run PID '${main_process_pid}'."
else
echo " - WARNING: No sunshine-run PID found."
fi
# Send a INT signal to the PID # Send a INT signal to the PID (if it is found)
echo " - Sending SIGINT to PID '${process_pid}'." if [ "X${main_process_pid:-}" != "X" ]; then
kill -INT "${process_pid}" || true echo " - Sending SIGINT to PID '${main_process_pid}'."
sleep 1 kill -INT "${main_process_pid}" || true
sleep 1
fi
# Run a loop to check for any other "sunshine-run" processes and send them also a INT signal # Run a loop to check for any other "sunshine-run" processes and send them also a INT signal
echo " - Checking for other sunshine-run processes..." echo " - Checking for other sunshine-run processes..."
@@ -74,7 +80,7 @@ for process_pid in $(ps aux | grep -v grep | grep sunshine-run | awk '{print $2}
echo " - ERROR: Failed to kill PID '${process_pid}'." echo " - ERROR: Failed to kill PID '${process_pid}'."
fi fi
done done
echo " - All sunshine-run related processes stopped." echo " - All sunshine-run related processes are stopped."
# Check if the required information was stored for resetting the display resolution and refresh rate # Check if the required information was stored for resetting the display resolution and refresh rate
if ([ "X${primary_output:-}" != "X" ] && [ "X${display_mode:-}" != "X" ] && [ "X${display_rate:-}" != "X" ]); then if ([ "X${primary_output:-}" != "X" ] && [ "X${display_mode:-}" != "X" ] && [ "X${display_rate:-}" != "X" ]); then