|
Hermes 0.7.0
Linux game streaming host
|
Let a Hermes that started before the graphical session catch up with it. More...
#include <map>#include <memory>#include <string>#include <string_view>#include <vector>#include "src/platform/common.h"Go to the source code of this file.
Typedefs | |
| using | platf::session_attach::environment_t = std::map<std::string, std::string> |
Functions | |
| environment_t | platf::session_attach::parse_environment (const std::vector< std::string > &assignments) |
| Split "NAME=value" assignments; entries without a name are dropped. | |
| environment_t | platf::session_attach::parse_environment_block (std::string_view block) |
| Parse an environment as the kernel keeps it: assignments separated by NUL bytes, as in /proc/self/environ. | |
| environment_t | platf::session_attach::initial_environment () |
| The environment Hermes was started with, not the one it has now. | |
| bool | platf::session_attach::attach_needed (const environment_t &own, const environment_t &session) |
Whether session names a display server that own does not talk to. | |
| std::vector< std::string > | platf::session_attach::merged_environment (const environment_t &own, const environment_t &session) |
own with every variable of session laid over it, as "NAME=value" strings ready for execve(). | |
| bool | platf::session_attach::display_server_reachable (const environment_t &environment) |
Whether a display server is listening where environment points. | |
| void | platf::session_attach::drop_stale_display_environment () |
| Forget display variables that point at a display server that is gone. | |
| std::vector< std::string > | platf::session_attach::restart_environment () |
| The environment the next restart must be given, as "NAME=value" strings for execve(). Read by platf::restart()'s re-exec. | |
| std::unique_ptr< platf::deinit_t > | platf::session_attach::start () |
| Start watching for a session to attach to. | |
Let a Hermes that started before the graphical session catch up with it.
Started at boot by a lingering user manager, Hermes has no display server in its environment, and a process cannot be handed one afterwards. Streaming the login screen and then the desktop needs none, but launching applications into the desktop, driving its layout and sharing its clipboard all do.
So once a session exists whose display variables Hermes does not carry, and no client has been connected for a moment, Hermes re-executes itself with the environment the user manager now holds - what systemctl --user restart hermes would have given it, without a stream to interrupt.
Definition in file session_attach.h.
| using platf::session_attach::environment_t = std::map<std::string, std::string> |
Definition at line 29 of file session_attach.h.
| bool platf::session_attach::attach_needed | ( | const environment_t & | own, |
| const environment_t & | session ) |
Whether session names a display server that own does not talk to.
Only the variables that select a display server and a desktop are compared; everything else in a session's environment is the session's business. A session that publishes no display server - gamescope-session does not - is never a reason to attach.
Definition at line 217 of file session_attach.cpp.
| bool platf::session_attach::display_server_reachable | ( | const environment_t & | environment | ) |
Whether a display server is listening where environment points.
Definition at line 179 of file session_attach.cpp.
| void platf::session_attach::drop_stale_display_environment | ( | ) |
Forget display variables that point at a display server that is gone.
A lingering user manager can keep the variables of a session after it ends, and hand them to a Hermes it starts afterwards. Qt aborts a process whose display variables point at nothing, and the tray is Qt: restarted into the same environment each time, Hermes would stay down on a machine that is by then waiting at its login screen. Call before anything reads the environment, while Hermes is still single-threaded.
Definition at line 187 of file session_attach.cpp.
| environment_t platf::session_attach::initial_environment | ( | ) |
The environment Hermes was started with, not the one it has now.
Hermes and its libraries adjust their own environment as they come up - the tray sets QT_QPA_PLATFORM=minimal when it finds no display, which before login is always. Carried into the re-exec, that one variable would be inherited by kscreen-doctor and every other Qt tool Hermes runs, none of which can reach Wayland through the minimal platform. What a restart of the unit would be given is the environment this process was started with, copied before main(), laid under what the user manager holds now. Not /proc/self/environ: with its file capabilities, the packaged Hermes is non-dumpable and cannot open it.
Definition at line 213 of file session_attach.cpp.
| std::vector< std::string > platf::session_attach::merged_environment | ( | const environment_t & | own, |
| const environment_t & | session ) |
own with every variable of session laid over it, as "NAME=value" strings ready for execve().
Definition at line 235 of file session_attach.cpp.
| environment_t platf::session_attach::parse_environment | ( | const std::vector< std::string > & | assignments | ) |
Split "NAME=value" assignments; entries without a name are dropped.
Definition at line 154 of file session_attach.cpp.
| environment_t platf::session_attach::parse_environment_block | ( | std::string_view | block | ) |
Parse an environment as the kernel keeps it: assignments separated by NUL bytes, as in /proc/self/environ.
Definition at line 166 of file session_attach.cpp.
| std::vector< std::string > platf::session_attach::restart_environment | ( | ) |
The environment the next restart must be given, as "NAME=value" strings for execve(). Read by platf::restart()'s re-exec.
The session's environment once Hermes is joining one. Otherwise the one Hermes was started with, never the live one: a restart from the Web UI or the tray before login would otherwise carry the tray's QT_QPA_PLATFORM=minimal into the next process, where it would look like part of the environment Hermes was started with and survive joining the session too. Empty only if neither can be read.
Definition at line 249 of file session_attach.cpp.
|
nodiscard |
Start watching for a session to attach to.
Definition at line 256 of file session_attach.cpp.