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
+1 -14
View File
@@ -18,21 +18,10 @@
#include <iostream>
#include <boost/process/environment.hpp>
#include "bridges/common.h"
namespace bp = boost::process;
using namespace std::literals::chrono_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";
uint32_t WINAPI
win32_thread_trampoline(fu2::unique_function<void()>* entry_point) {
(*entry_point)();
@@ -94,12 +83,10 @@ MainContext::MainContext()
events_timer(context),
watchdog_context(),
watchdog_timer(watchdog_context) {
bp::environment env = boost::this_process::environment();
// NOTE: We allow disabling the watchdog timer to allow the Wine process to
// be run from a separate namespace. This is not something you'd
// normally want to enable.
if (env[disable_watchdog_timer_env_var].to_string() == "1") {
if (is_watchdog_timer_disabled()) {
std::cerr << "WARNING: Watchdog timer disabled. Not protecting"
<< std::endl;
std::cerr << " against dangling processes." << std::endl;