aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Saleem Abdulrasool <compnerd@gentoo.org> 2006-02-09 04:12:52 +0000
committerAvatar Saleem Abdulrasool <compnerd@gentoo.org> 2006-02-09 04:12:52 +0000
commitf2a627c66bedb9e3b3f0093c1e2f25cdf22a5b4e (patch)
tree91763bccf4a6b02b35e52cbc0507a6dd750fb5a4
parent19585d0f50885e1ad22001ce16dd9d8ea06840f7 (diff)
downloadpaludis-f2a627c66bedb9e3b3f0093c1e2f25cdf22a5b4e.tar.gz
paludis-f2a627c66bedb9e3b3f0093c1e2f25cdf22a5b4e.tar.xz
Disable alarms when being traced
-rw-r--r--test/test_runner.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/test_runner.cc b/test/test_runner.cc
index 6eba9c2..52f9226 100644
--- a/test/test_runner.cc
+++ b/test/test_runner.cc
@@ -25,6 +25,7 @@
#include <signal.h>
#include <execinfo.h>
#include <unistd.h>
+#include <sys/ptrace.h>
/** \file
* Implementation of the default test runner.
@@ -67,8 +68,12 @@ void segfault_handler(int)
int
main(int, char * argv[])
{
- signal(SIGALRM, &timeout_handler);
- signal(SIGSEGV, &segfault_handler);
+ // if ptrace returns < 0, then it is being traced
+ if (ptrace(PTRACE_TRACEME, 0, 1, 0) >= 0)
+ {
+ signal(SIGALRM, &timeout_handler);
+ signal(SIGSEGV, &segfault_handler);
+ }
std::cout << "Test program " << argv[0] << ":" << std::endl;
return TestCaseList::run_tests() ? EXIT_SUCCESS : EXIT_FAILURE;