mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 02:23:51 +00:00
Change is_debugger_attached to a different hack
This commit is contained in:
parent
883140babf
commit
20d806b40c
1 changed files with 8 additions and 21 deletions
|
@ -432,31 +432,18 @@ int cc_install_handlers(int argc, char **argv, int num_signals, int *signals, co
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// gdb apparently opens FD(s) 3,4,5 (whereas a typical prog uses only stdin=0, stdout=1,stderr=2)
|
||||||
|
|
||||||
static void*
|
|
||||||
test_trace(void* ignored)
|
|
||||||
{
|
|
||||||
return (void*)ptrace(PTRACE_TRACEME, 0, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
is_debugger_attached(void)
|
is_debugger_attached(void)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
bool rc = false;
|
||||||
void* result;
|
FILE *fd = fopen("/tmp", "r");
|
||||||
pthread_t thread;
|
|
||||||
|
|
||||||
pthread_attr_init(&attr);
|
if (fileno(fd) > 5)
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
|
{
|
||||||
if (pthread_create(&thread, &attr, test_trace, NULL) != 0) {
|
rc = true;
|
||||||
pthread_attr_destroy(&attr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pthread_attr_destroy(&attr);
|
|
||||||
if (pthread_join(thread, &result) != 0) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result != NULL;
|
fclose(fd);
|
||||||
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue