1 Return-Path: <bart@jukie.net>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 4773D431FAE
\r
6 for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 19:11:54 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
8 Received: from olra.theworths.org ([127.0.0.1])
\r
9 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
10 with ESMTP id 6RGIAAiicpVn for <notmuch@notmuchmail.org>;
\r
11 Fri, 27 Nov 2009 19:11:53 -0800 (PST)
\r
12 Received: from tau.jukie.net (tau.jukie.net [216.239.93.128])
\r
13 by olra.theworths.org (Postfix) with ESMTP id 4136D431FBC
\r
14 for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 19:11:53 -0800 (PST)
\r
15 Received: from localhost.localdomain (oxygen.jukie.net [10.10.10.8])
\r
16 by tau.jukie.net (Postfix) with ESMTP id B1B37C008F5;
\r
17 Fri, 27 Nov 2009 22:11:52 -0500 (EST)
\r
18 From: Bart Trojanowski <bart@jukie.net>
\r
19 To: notmuch@notmuchmail.org
\r
20 Date: Fri, 27 Nov 2009 22:11:04 -0500
\r
21 Message-Id: <1259377864-2523-1-git-send-email-bart@jukie.net>
\r
22 X-Mailer: git-send-email 1.6.4.4.2.gc2f148
\r
23 Cc: Bart Trojanowski <bart@jukie.net>
\r
24 Subject: [notmuch] [PATCH RFC] debugger: detect presence of ptrace type
\r
26 X-BeenThere: notmuch@notmuchmail.org
\r
27 X-Mailman-Version: 2.1.12
\r
29 List-Id: "Use and development of the notmuch mail system."
\r
30 <notmuch.notmuchmail.org>
\r
31 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
32 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
33 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
34 List-Post: <mailto:notmuch@notmuchmail.org>
\r
35 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
36 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
37 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
38 X-List-Received-Date: Sat, 28 Nov 2009 03:11:54 -0000
\r
40 According to the internet [1], this is a more reliable way of detecting if
\r
41 one is under the spell of a debugger. Should work for ptrace, strace,
\r
42 gdb, etc. Basically anything that uses the ptrace() syscall.
\r
44 [1] http://vx.netlux.org/lib/vsc04.html
\r
46 debugger.c | 5 +++++
\r
47 1 files changed, 5 insertions(+), 0 deletions(-)
\r
49 diff --git a/debugger.c b/debugger.c
\r
50 index e8b9378..f486032 100644
\r
57 +#include <sys/ptrace.h>
\r
60 #include <valgrind.h>
\r
62 @@ -36,6 +38,9 @@ debugger_is_active (void)
\r
63 if (RUNNING_ON_VALGRIND)
\r
66 + if (ptrace(PTRACE_TRACEME, 0, 1, 0) < 0)
\r
69 sprintf (buf, "/proc/%d/exe", getppid ());
\r
70 if (readlink (buf, buf, sizeof (buf)) != -1 &&
\r
71 strncmp (basename (buf), "gdb", 3) == 0)
\r