* [PATCH RFC] debugger: detect presence of ptrace type debuggers
@ 2009-11-28 3:11 Bart Trojanowski
2009-11-28 6:17 ` Carl Worth
0 siblings, 1 reply; 2+ messages in thread
From: Bart Trojanowski @ 2009-11-28 3:11 UTC (permalink / raw)
To: notmuch; +Cc: Bart Trojanowski
According to the internet [1], this is a more reliable way of detecting if
one is under the spell of a debugger. Should work for ptrace, strace,
gdb, etc. Basically anything that uses the ptrace() syscall.
[1] http://vx.netlux.org/lib/vsc04.html
---
debugger.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/debugger.c b/debugger.c
index e8b9378..f486032 100644
--- a/debugger.c
+++ b/debugger.c
@@ -22,6 +22,8 @@
#include <libgen.h>
+#include <sys/ptrace.h>
+
#if HAVE_VALGRIND
#include <valgrind.h>
#else
@@ -36,6 +38,9 @@ debugger_is_active (void)
if (RUNNING_ON_VALGRIND)
return TRUE;
+ if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
+ return TRUE;
+
sprintf (buf, "/proc/%d/exe", getppid ());
if (readlink (buf, buf, sizeof (buf)) != -1 &&
strncmp (basename (buf), "gdb", 3) == 0)
--
1.6.4.4.2.gc2f148
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RFC] debugger: detect presence of ptrace type debuggers
2009-11-28 3:11 [PATCH RFC] debugger: detect presence of ptrace type debuggers Bart Trojanowski
@ 2009-11-28 6:17 ` Carl Worth
0 siblings, 0 replies; 2+ messages in thread
From: Carl Worth @ 2009-11-28 6:17 UTC (permalink / raw)
To: Bart Trojanowski, notmuch; +Cc: Bart Trojanowski
[-- Attachment #1: Type: text/plain, Size: 476 bytes --]
On Fri, 27 Nov 2009 22:11:04 -0500, Bart Trojanowski <bart@jukie.net> wrote:
> According to the internet [1], this is a more reliable way of detecting if
> one is under the spell of a debugger. Should work for ptrace, strace,
> gdb, etc. Basically anything that uses the ptrace() syscall.
Doesn't avoid having side effects in the non-debugger case:
$ ./notmuch new
No new mail---and that's not much.
[1]+ Stopped ./notmuch new
$
Not pushed.
-Carl
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-11-28 6:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-28 3:11 [PATCH RFC] debugger: detect presence of ptrace type debuggers Bart Trojanowski
2009-11-28 6:17 ` Carl Worth
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).