mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-11 03:06:42 +00:00
Merged merge request !26
This commit is contained in:
commit
0142525ea2
1 changed files with 34 additions and 0 deletions
|
@ -32,6 +32,10 @@ namespace bfs = boost::filesystem;
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <sys/sysctl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
|
|
||||||
static const char crash_switch[] = "--cc-handle-crash";
|
static const char crash_switch[] = "--cc-handle-crash";
|
||||||
|
@ -460,6 +464,7 @@ int crashCatcherInstallHandlers(int argc, char **argv, int num_signals, int *sig
|
||||||
|
|
||||||
static bool is_debugger_present()
|
static bool is_debugger_present()
|
||||||
{
|
{
|
||||||
|
#if !defined (__APPLE__)
|
||||||
bfs::ifstream file((bfs::path("/proc/self/status")));
|
bfs::ifstream file((bfs::path("/proc/self/status")));
|
||||||
while (!file.eof())
|
while (!file.eof())
|
||||||
{
|
{
|
||||||
|
@ -472,6 +477,35 @@ static bool is_debugger_present()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
#else
|
||||||
|
int junk;
|
||||||
|
int mib[4];
|
||||||
|
struct kinfo_proc info;
|
||||||
|
size_t size;
|
||||||
|
|
||||||
|
// Initialize the flags so that, if sysctl fails for some bizarre
|
||||||
|
// reason, we get a predictable result.
|
||||||
|
|
||||||
|
info.kp_proc.p_flag = 0;
|
||||||
|
|
||||||
|
// Initialize mib, which tells sysctl the info we want, in this case
|
||||||
|
// we're looking for information about a specific process ID.
|
||||||
|
|
||||||
|
mib[0] = CTL_KERN;
|
||||||
|
mib[1] = KERN_PROC;
|
||||||
|
mib[2] = KERN_PROC_PID;
|
||||||
|
mib[3] = getpid();
|
||||||
|
|
||||||
|
// Call sysctl.
|
||||||
|
|
||||||
|
size = sizeof(info);
|
||||||
|
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
|
||||||
|
assert(junk == 0);
|
||||||
|
|
||||||
|
// We're being debugged if the P_TRACED flag is set.
|
||||||
|
|
||||||
|
return (info.kp_proc.p_flag & P_TRACED) != 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void crashCatcherInstall(int argc, char **argv, const std::string &crashLogPath)
|
void crashCatcherInstall(int argc, char **argv, const std::string &crashLogPath)
|
||||||
|
|
Loading…
Reference in a new issue