12 #define __kernel_entry
17#include <unordered_map>
30#define DEFAULT_APP_IMAGE_PATH SUNSHINE_ASSETS_DIR "/box.png"
98 boost::process::v1::environment &&env,
99 std::vector<
ctx_t> &&apps
102 _env(std::move(env)),
103 _apps(std::move(apps)) {
113 int execute(
int app_id, std::shared_ptr<rtsp_stream::launch_session_t> launch_session);
127 const std::vector<ctx_t> &
get_apps()
const;
176 std::vector<ctx_t> _apps;
178 std::chrono::steady_clock::time_point _app_launch_time;
183 boost::process::v1::child _process;
184 boost::process::v1::group _process_group;
187 std::vector<cmd_t>::const_iterator _app_prep_it;
188 std::vector<cmd_t>::const_iterator _app_prep_begin;
199 std::tuple<std::string, std::string>
calculate_app_id(
const std::string &app_name, std::string app_image_path,
int index);
222 void refresh(
const std::string &file_name);
229 std::optional<proc::proc_t>
parse(
const std::string &file_name);
235 std::unique_ptr<platf::deinit_t>
init();
243 void terminate_process_group(boost::process::v1::child &child_process, boost::process::v1::group &group, std::chrono::seconds exit_timeout);
Includes Boost.Process while isolating third-party deprecation diagnostics.
Tracks launched child processes and terminates them during shutdown.
Definition process.h:87
std::string get_app_image(int app_id)
Get app image.
Definition process.cpp:409
int running()
Definition process.cpp:311
void update_apps_and_env(proc_t &&other)
Update the cached app list and environment without disturbing running process state.
Definition process.cpp:422
void terminate()
Terminate the launched application process.
Definition process.cpp:346
int execute(int app_id, std::shared_ptr< rtsp_stream::launch_session_t > launch_session)
Launch the configured application process.
Definition process.cpp:173
std::string get_last_run_app_name()
Get last run app name.
Definition process.cpp:418
const std::vector< ctx_t > & get_apps() const
Return the configured applications.
Definition process.cpp:397
proc_t(proc_t &&)=default
Defaulted move constructor for the generated type.
Declarations for common platform specific utilities.
basic_environment< char > environment
Map of environment variable names to values.
Definition common.h:68
Declarations for the configuration of Sunshine.
void refresh(const std::string &file_name)
Refresh cached platform state from the operating system.
Definition process.cpp:853
std::string prepare_command(const std::string &command)
Prepare a configured command for execution.
Definition process.cpp:156
std::unique_ptr< platf::deinit_t > init()
Initialize proc functions.
Definition process.cpp:66
proc_t proc
Global process registry used to track and terminate child processes.
Definition process.cpp:51
bool check_valid_png(const std::filesystem::path &path)
Validates a path whether it is a valid PNG.
Definition process.cpp:540
std::tuple< std::string, std::string > calculate_app_id(const std::string &app_name, std::string app_image_path, int index)
Calculate a stable id based on name and image data.
Definition process.cpp:672
std::optional< proc::proc_t > parse(const std::string &file_name)
Parse serialized text into the corresponding runtime representation.
Definition process.cpp:706
void terminate_process_group(boost::process::v1::child &child_process, boost::process::v1::group &group, std::chrono::seconds exit_timeout)
Terminates all child processes in a process group.
Definition process.cpp:70
std::string validate_app_image_path(std::string app_image_path)
Validate app image path.
Definition process.cpp:572
config::prep_cmd_t cmd_t
Parsed command arguments used when launching a child process.
Definition process.h:41
util::safe_ptr_v2< FILE, int, &fclose > file_t
Boost.Process pipe stream used for child-process I/O.
Definition process.h:36
Declarations for RTSP streaming.
External preparation command plus its privilege requirement.
Definition config.h:342
std::string id
Stable identifier for the configured application.
Definition process.h:77
std::string working_dir
Working dir.
Definition process.h:74
bool elevated
Whether the process should be launched elevated.
Definition process.h:78
bool wait_all
Whether Sunshine waits for all child processes.
Definition process.h:80
std::vector< cmd_t > prep_cmds
Prep cmds.
Definition process.h:56
std::chrono::seconds exit_timeout
Exit timeout.
Definition process.h:81
std::vector< std::string > detached
Definition process.h:70
std::string cmd
Command line used to launch the application.
Definition process.h:73
std::string image_path
Image path.
Definition process.h:76
std::string name
Human-readable name for this item.
Definition process.h:72
bool auto_detach
Whether the process should detach automatically.
Definition process.h:79
std::string output
Captured output from the launched process.
Definition process.h:75
Declarations for utility functions.
uniq_ptr< T, Destroy< T *, ReturnType, function > > safe_ptr_v2
Safe pointer wrapper for APIs whose release function returns a status value.
Definition utility.h:1597
#define KITTY_DEFAULT_CONSTR_MOVE_THROW(x)
Declare defaulted move construction and assignment that may throw.
Definition utility.h:133