Move watchdog timer disable check to common/utils

We may also want to check this from the plugin.
This commit is contained in:
Robbert van der Helm
2021-06-22 17:04:52 +02:00
parent 333707255e
commit 8873c11e1d
3 changed files with 27 additions and 14 deletions
+16
View File
@@ -23,6 +23,15 @@
namespace bp = boost::process;
namespace fs = boost::filesystem;
using namespace std::literals::string_literals;
/**
* If this environment variable is set to `1`, then we won't enable the watchdog
* timer. This is only necessary when running the Wine process under a different
* namespace than the host.
*/
constexpr char disable_watchdog_timer_env_var[] = "YABRIDGE_NO_WATCHDOG";
fs::path get_temporary_directory() {
bp::environment env = boost::this_process::environment();
if (!env["XDG_RUNTIME_DIR"].empty()) {
@@ -57,6 +66,13 @@ std::optional<rlim_t> get_rttime_limit() noexcept {
}
}
bool is_watchdog_timer_disabled() {
// This is safe because we're not storing the pointer anywhere and the
// environment doesn't get modified anywhere
// NOLINTNEXTLINE(concurrency-mt-unsafe)
return getenv(disable_watchdog_timer_env_var) == "1"s;
}
bool pid_running(pid_t pid) {
// With regular individually hosted plugins we can simply check whether the
// process is still running, however Boost.Process does not allow you to do