process#

Include dependency graph for process.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "23" [label="atomic" tooltip="atomic"]
    "18" [label="src/stat_trackers.h" tooltip="src/stat_trackers.h"]
    "13" [label="functional" tooltip="functional"]
    "19" [label="limits" tooltip="limits"]
    "17" [label="boost/log/sinks.hpp" tooltip="boost/log/sinks.hpp"]
    "38" [label="openssl/rand.h" tooltip="openssl/rand.h"]
    "12" [label="filesystem" tooltip="filesystem"]
    "31" [label="variant" tooltip="variant"]
    "40" [label="openssl/x509.h" tooltip="openssl/x509.h"]
    "20" [label="boost/format.hpp" tooltip="boost/format.hpp"]
    "39" [label="openssl/sha.h" tooltip="openssl/sha.h"]
    "8" [label="string" tooltip="string"]
    "25" [label="map" tooltip="map"]
    "35" [label="rtsp.h" tooltip="rtsp.h"]
    "26" [label="utility.h" tooltip="utility.h"]
    "5" [label="config.h" tooltip="config.h"]
    "11" [label="platform/common.h" tooltip="platform/common.h"]
    "29" [label="string_view" tooltip="string_view"]
    "24" [label="condition_variable" tooltip="condition_variable"]
    "32" [label="src/video_colorspace.h" tooltip="src/video_colorspace.h"]
    "10" [label="nvenc/nvenc_config.h" tooltip="nvenc/nvenc_config.h"]
    "6" [label="bitset" tooltip="bitset"]
    "33" [label="libavutil/pixfmt.h" tooltip="libavutil/pixfmt.h"]
    "2" [label="optional" tooltip="optional"]
    "9" [label="vector" tooltip="vector"]
    "1" [label="src/process.h" tooltip="src/process.h" fillcolor="#BFBFBF"]
    "22" [label="array" tooltip="array"]
    "4" [label="boost/process.hpp" tooltip="boost/process.hpp"]
    "15" [label="src/logging.h" tooltip="src/logging.h"]
    "37" [label="openssl/evp.h" tooltip="openssl/evp.h"]
    "3" [label="unordered_map" tooltip="unordered_map"]
    "14" [label="mutex" tooltip="mutex"]
    "7" [label="chrono" tooltip="chrono"]
    "36" [label="crypto.h" tooltip="crypto.h"]
    "30" [label="type_traits" tooltip="type_traits"]
    "34" [label="moonlight-common-c/src/Limelight.h" tooltip="moonlight-common-c/src/Limelight.h"]
    "16" [label="boost/log/common.hpp" tooltip="boost/log/common.hpp"]
    "27" [label="algorithm" tooltip="algorithm"]
    "28" [label="memory" tooltip="memory"]
    "21" [label="src/thread_safe.h" tooltip="src/thread_safe.h"]
    "18" -> "7" [dir=forward tooltip="include"]
    "18" -> "13" [dir=forward tooltip="include"]
    "18" -> "19" [dir=forward tooltip="include"]
    "18" -> "20" [dir=forward tooltip="include"]
    "35" -> "23" [dir=forward tooltip="include"]
    "35" -> "36" [dir=forward tooltip="include"]
    "35" -> "21" [dir=forward tooltip="include"]
    "26" -> "27" [dir=forward tooltip="include"]
    "26" -> "24" [dir=forward tooltip="include"]
    "26" -> "28" [dir=forward tooltip="include"]
    "26" -> "14" [dir=forward tooltip="include"]
    "26" -> "2" [dir=forward tooltip="include"]
    "26" -> "8" [dir=forward tooltip="include"]
    "26" -> "29" [dir=forward tooltip="include"]
    "26" -> "30" [dir=forward tooltip="include"]
    "26" -> "31" [dir=forward tooltip="include"]
    "26" -> "9" [dir=forward tooltip="include"]
    "5" -> "6" [dir=forward tooltip="include"]
    "5" -> "7" [dir=forward tooltip="include"]
    "5" -> "2" [dir=forward tooltip="include"]
    "5" -> "8" [dir=forward tooltip="include"]
    "5" -> "3" [dir=forward tooltip="include"]
    "5" -> "9" [dir=forward tooltip="include"]
    "5" -> "10" [dir=forward tooltip="include"]
    "11" -> "6" [dir=forward tooltip="include"]
    "11" -> "12" [dir=forward tooltip="include"]
    "11" -> "13" [dir=forward tooltip="include"]
    "11" -> "14" [dir=forward tooltip="include"]
    "11" -> "8" [dir=forward tooltip="include"]
    "11" -> "5" [dir=forward tooltip="include"]
    "11" -> "15" [dir=forward tooltip="include"]
    "11" -> "18" [dir=forward tooltip="include"]
    "11" -> "21" [dir=forward tooltip="include"]
    "11" -> "26" [dir=forward tooltip="include"]
    "11" -> "32" [dir=forward tooltip="include"]
    "11" -> "34" [dir=forward tooltip="include"]
    "32" -> "33" [dir=forward tooltip="include"]
    "1" -> "2" [dir=forward tooltip="include"]
    "1" -> "3" [dir=forward tooltip="include"]
    "1" -> "4" [dir=forward tooltip="include"]
    "1" -> "5" [dir=forward tooltip="include"]
    "1" -> "11" [dir=forward tooltip="include"]
    "1" -> "35" [dir=forward tooltip="include"]
    "1" -> "26" [dir=forward tooltip="include"]
    "15" -> "16" [dir=forward tooltip="include"]
    "15" -> "17" [dir=forward tooltip="include"]
    "36" -> "22" [dir=forward tooltip="include"]
    "36" -> "37" [dir=forward tooltip="include"]
    "36" -> "38" [dir=forward tooltip="include"]
    "36" -> "39" [dir=forward tooltip="include"]
    "36" -> "40" [dir=forward tooltip="include"]
    "36" -> "26" [dir=forward tooltip="include"]
    "21" -> "22" [dir=forward tooltip="include"]
    "21" -> "23" [dir=forward tooltip="include"]
    "21" -> "24" [dir=forward tooltip="include"]
    "21" -> "13" [dir=forward tooltip="include"]
    "21" -> "25" [dir=forward tooltip="include"]
    "21" -> "14" [dir=forward tooltip="include"]
    "21" -> "9" [dir=forward tooltip="include"]
    "21" -> "26" [dir=forward tooltip="include"]
}

This graph shows which files directly or indirectly include process.h:

digraph {
    graph [bgcolor="#00000000"]
    node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
    edge [color="#1414CE"]
    "6" [label="src/stream.cpp" tooltip="src/stream.cpp"]
    "1" [label="src/process.h" tooltip="src/process.h" fillcolor="#BFBFBF"]
    "5" [label="src/process.cpp" tooltip="src/process.cpp"]
    "4" [label="src/main.cpp" tooltip="src/main.cpp"]
    "2" [label="src/confighttp.cpp" tooltip="src/confighttp.cpp"]
    "3" [label="src/httpcommon.cpp" tooltip="src/httpcommon.cpp"]
    "1" -> "2" [dir=back tooltip="include"]
    "1" -> "3" [dir=back tooltip="include"]
    "1" -> "4" [dir=back tooltip="include"]
    "1" -> "5" [dir=back tooltip="include"]
    "1" -> "6" [dir=back tooltip="include"]
}

todo

Defines

__kernel_entry#
namespace proc#

Typedefs

typedef config::prep_cmd_t cmd_t#
using file_t = util::safe_ptr_v2<FILE, int, fclose>#
struct ctx_t#
#include <src/process.h>

pre_cmds &#8212; guaranteed to be executed unless any of the commands fail. detached &#8212; commands detached from Sunshine cmd &#8212; Runs indefinitely until: No session is running and a different set of commands it to be executed Command exits working_dir &#8212; the process working directory. This is required for some games to run properly. cmd_output &#8212; empty &#8212; The output of the commands are appended to the output of sunshine “null” &#8212; The output of the commands are discarded filename &#8212; The output of the commands are appended to filename

Public Members

bool auto_detach#
std::string cmd#
std::vector<std::string> detached#

Some applications, such as Steam, either exit quickly, or keep running indefinitely.

Apps that launch normal child processes and terminate will be handled by the process grouping logic (wait_all). However, apps that launch child processes indirectly or into another process group (such as UWP apps) can only be handled by the auto-detach heuristic which catches processes that exit 0 very quickly, but we won’t have proper process tracking for those.

For cases where users just want to kick off a background process and never manage the lifetime of that process, they can use detached commands for that.

bool elevated#
std::chrono::seconds exit_timeout#
std::string id#
std::string image_path#
std::string name#
std::string output#
std::vector<cmd_t> prep_cmds#
bool wait_all#
std::string working_dir#
class proc_t#

Public Functions

int execute(int app_id, std::shared_ptr<rtsp_stream::launch_session_t> launch_session)#
std::string get_app_image(int app_id)#
std::vector<ctx_t> &get_apps()#
const std::vector<ctx_t> &get_apps() const#
std::string get_last_run_app_name()#
proc_t &operator=(proc_t&&) = default#
proc_t() = default#
inline proc_t(boost::process::environment &&env, std::vector<ctx_t> &&apps)#
proc_t(proc_t&&) = default#
int running()#
Returns:

_app_id if a process is running, otherwise returns 0

void terminate()#
~proc_t()#

Private Members

ctx_t _app#
int _app_id#
std::chrono::steady_clock::time_point _app_launch_time#
std::vector<cmd_t>::const_iterator _app_prep_begin#
std::vector<cmd_t>::const_iterator _app_prep_it#
std::vector<ctx_t> _apps#
boost::process::environment _env#
file_t _pipe#
boost::process::child _process#
boost::process::group _process_group#
bool placebo = {}#