Add debugger detector for Linux

This commit is contained in:
noisyfox
2025-06-02 16:48:58 +08:00
parent 1441da246b
commit fc33a680d1
3 changed files with 24 additions and 1 deletions

View File

@@ -495,5 +495,26 @@ void fit_in_display(wxTopLevelWindow& window, wxSize desired_size)
window.SetSize(desired_size);
}
#ifdef __linux__
// Detect if the application is running inside a debugger.
// https://stackoverflow.com/a/69842462/3289421
bool is_debugger_present() {
std::ifstream sf("/proc/self/status");
std::string s;
while (sf >> s)
{
if (s == "TracerPid:")
{
int pid;
sf >> pid;
return pid != 0;
}
std::getline(sf, s);
}
return false;
}
#endif
}
}