From daaec4ba468038299244f52c3964db1fb23dc350 Mon Sep 17 00:00:00 2001 From: loki Date: Mon, 30 Dec 2019 23:23:28 +0100 Subject: [PATCH] Fix issue where quitting app no longer works after exiting a process in stream --- sunshine/process.cpp | 8 ++++++++ sunshine/process.h | 1 + 2 files changed, 9 insertions(+) diff --git a/sunshine/process.cpp b/sunshine/process.cpp index cd3c7b44..a2a2b8bd 100644 --- a/sunshine/process.cpp +++ b/sunshine/process.cpp @@ -42,6 +42,13 @@ int exe(const std::string &cmd, bp::environment &env, file_t &file, std::error_c } int proc_t::execute(int app_id) { + if(!_process.running() && _app_id != -1) { + // previous process exited on it's own, reset _process_handle + _process_handle = bp::group(); + + _app_id = -1; + } + if(app_id >= _apps.size()) { std::cout << "Error: Couldn't find app with ID ["sv << app_id << ']' << std::endl; @@ -115,6 +122,7 @@ void proc_t::terminate() { // Ensure child process is terminated process_end(_process, _process_handle); + _app_id = -1; if(ec) { std::cout << "FATAL Error: System: "sv << ec.message() << std::endl; diff --git a/sunshine/process.h b/sunshine/process.h index df24bbcf..1c4e11da 100644 --- a/sunshine/process.h +++ b/sunshine/process.h @@ -49,6 +49,7 @@ public: proc_t( boost::process::environment &&env, std::vector &&apps) : + _app_id(-1), _env(std::move(env)), _apps(std::move(apps)) {}