Re: notmuch-reply doesn't use Reply-To
[notmuch-archives.git] / 89 / ce9cd731123d0c5f4733617f3cf709fd58cdfe
1 Return-Path: <chris@chris-wilson.co.uk>\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 79945431FAE\r
6         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:33:27 -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 uuiL7mpWFeIq for <notmuch@notmuchmail.org>;\r
11         Sat, 21 Nov 2009 16:33:26 -0800 (PST)\r
12 Received: from orsmga101.jf.intel.com (mga06.intel.com [134.134.136.21])\r
13         by olra.theworths.org (Postfix) with ESMTP id 133B8431FBC\r
14         for <notmuch@notmuchmail.org>; Sat, 21 Nov 2009 16:33:25 -0800 (PST)\r
15 Received: from orsmga001.jf.intel.com ([10.7.209.18])\r
16         by orsmga101.jf.intel.com with ESMTP; 21 Nov 2009 16:33:16 -0800\r
17 X-ExtLoop1: 1\r
18 X-IronPort-AV: E=Sophos;i="4.47,265,1257148800"; d="scan'208";a="571886901"\r
19 Received: from unknown (HELO localhost.localdomain) ([10.255.16.190])\r
20         by orsmga001.jf.intel.com with ESMTP; 21 Nov 2009 16:33:13 -0800\r
21 From: Chris Wilson <chris@chris-wilson.co.uk>\r
22 To: notmuch@notmuchmail.org\r
23 Date: Sun, 22 Nov 2009 00:33:19 +0000\r
24 Message-Id: <1258849999-27513-1-git-send-email-chris@chris-wilson.co.uk>\r
25 X-Mailer: git-send-email 1.6.5.3\r
26 In-Reply-To: <1258849350-27213-1-git-send-email-chris@chris-wilson.co.uk>\r
27 References: <1258849350-27213-1-git-send-email-chris@chris-wilson.co.uk>\r
28 Subject: [notmuch] [PATCH] notmuch-new: Only install SIGALRM if not running\r
29         under gdb\r
30 X-BeenThere: notmuch@notmuchmail.org\r
31 X-Mailman-Version: 2.1.12\r
32 Precedence: list\r
33 List-Id: "Use and development of the notmuch mail system."\r
34         <notmuch.notmuchmail.org>\r
35 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
36         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
37 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
38 List-Post: <mailto:notmuch@notmuchmail.org>\r
39 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
40 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
41         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
42 X-List-Received-Date: Sun, 22 Nov 2009 00:33:27 -0000\r
43 \r
44 I felt sorry for Carl trying to step through an exception from xapian\r
45 and suffering from the SIGALARMs..\r
46 \r
47 We can detect if the user launched notmuch under a debugger by either\r
48 checking our cmdline for the presence of the gdb string or querying if\r
49 valgrind is controlling our process. For the latter we need to add a\r
50 compile time check for the valgrind development library, and so add the\r
51 initial support to build Makefile.config from configure.\r
52 \r
53 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>\r
54 Reviewed-by: Carl Worth <cworth@cworth.org>\r
55 [ickle: And do not install the timer]\r
56 ---\r
57  Makefile.config  |    1 +\r
58  Makefile.local   |    3 ++-\r
59  configure        |   21 +++++++++++++++++----\r
60  debugger.c       |   47 +++++++++++++++++++++++++++++++++++++++++++++++\r
61  notmuch-client.h |    3 +++\r
62  notmuch-new.c    |   12 +++++++-----\r
63  6 files changed, 77 insertions(+), 10 deletions(-)\r
64  create mode 100644 debugger.c\r
65 \r
66 diff --git a/Makefile.config b/Makefile.config\r
67 index d72a39e..ddc7436 100644\r
68 --- a/Makefile.config\r
69 +++ b/Makefile.config\r
70 @@ -1,2 +1,3 @@\r
71  prefix = /usr/local\r
72  bash_completion_dir = /etc/bash_completion.d\r
73 +CFLAGS += -DHAVE_VALGRIND\r
74 diff --git a/Makefile.local b/Makefile.local\r
75 index 3c99624..efe76c8 100644\r
76 --- a/Makefile.local\r
77 +++ b/Makefile.local\r
78 @@ -3,6 +3,8 @@ all: notmuch notmuch.1.gz\r
79  emacs: notmuch.elc\r
80  \r
81  notmuch_client_srcs =          \\r
82 +       debugger.c              \\r
83 +       gmime-filter-reply.c    \\r
84         notmuch.c               \\r
85         notmuch-config.c        \\r
86         notmuch-dump.c          \\r
87 @@ -14,7 +16,6 @@ notmuch_client_srcs =         \\r
88         notmuch-show.c          \\r
89         notmuch-tag.c           \\r
90         notmuch-time.c          \\r
91 -       gmime-filter-reply.c    \\r
92         query-string.c          \\r
93         show-message.c\r
94  \r
95 diff --git a/configure b/configure\r
96 index fe46c8e..b4770ec 100755\r
97 --- a/configure\r
98 +++ b/configure\r
99 @@ -53,6 +53,14 @@ else\r
100      errors=$((errors + 1))\r
101  fi\r
102  \r
103 +if pkg-config --modversion valgrind > /dev/null 2>&1; then\r
104 +    echo "Checking for valgrind development files... Yes."\r
105 +    have_valgrind=-DHAVE_VALGRIND\r
106 +else\r
107 +    echo "Checking for valgrind development files... No."\r
108 +    have_valgrind=\r
109 +fi\r
110 +\r
111  if [ $errors -gt 0 ]; then\r
112      cat <<EOF\r
113  \r
114 @@ -108,7 +116,8 @@ configure again to ensure the packages can be found, or simply run\r
115  \r
116  EOF\r
117      exit 1\r
118 -else\r
119 +fi\r
120 +\r
121  cat <<EOF\r
122  \r
123  All required packages were found. You may now run the following\r
124 @@ -118,6 +127,10 @@ commands to compile and install notmuch:\r
125         sudo make install\r
126  \r
127  EOF\r
128 -    exit 0\r
129 -fi\r
130 -cat <<EOF\r
131 +\r
132 +# construct the Makefile.config\r
133 +cat > Makefile.config <<EOF\r
134 +prefix = /usr/local\r
135 +bash_completion_dir = /etc/bash_completion.d\r
136 +CFLAGS += ${have_valgrind}\r
137 +EOF\r
138 diff --git a/debugger.c b/debugger.c\r
139 new file mode 100644\r
140 index 0000000..e8b9378\r
141 --- /dev/null\r
142 +++ b/debugger.c\r
143 @@ -0,0 +1,47 @@\r
144 +/* debugger.c - Some debugger utilities for the notmuch mail library\r
145 + *\r
146 + * Copyright © 2009 Chris Wilson\r
147 + *\r
148 + * This program is free software: you can redistribute it and/or modify\r
149 + * it under the terms of the GNU General Public License as published by\r
150 + * the Free Software Foundation, either version 3 of the License, or\r
151 + * (at your option) any later version.\r
152 + *\r
153 + * This program is distributed in the hope that it will be useful,\r
154 + * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
155 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
156 + * GNU General Public License for more details.\r
157 + *\r
158 + * You should have received a copy of the GNU General Public License\r
159 + * along with this program.  If not, see http://www.gnu.org/licenses/ .\r
160 + *\r
161 + * Author: Chris Wilson <chris@chris-wilson.co.uk>\r
162 + */\r
163 +\r
164 +#include "notmuch-client.h"\r
165 +\r
166 +#include <libgen.h>\r
167 +\r
168 +#if HAVE_VALGRIND\r
169 +#include <valgrind.h>\r
170 +#else\r
171 +#define RUNNING_ON_VALGRIND 0\r
172 +#endif\r
173 +\r
174 +notmuch_bool_t\r
175 +debugger_is_active (void)\r
176 +{\r
177 +    char buf[1024];\r
178 +\r
179 +    if (RUNNING_ON_VALGRIND)\r
180 +       return TRUE;\r
181 +\r
182 +    sprintf (buf, "/proc/%d/exe", getppid ());\r
183 +    if (readlink (buf, buf, sizeof (buf)) != -1 &&\r
184 +       strncmp (basename (buf), "gdb", 3) == 0)\r
185 +    {\r
186 +       return TRUE;\r
187 +    }\r
188 +\r
189 +    return FALSE;\r
190 +}\r
191 diff --git a/notmuch-client.h b/notmuch-client.h\r
192 index b65aa77..ea77686 100644\r
193 --- a/notmuch-client.h\r
194 +++ b/notmuch-client.h\r
195 @@ -179,4 +179,7 @@ notmuch_config_set_user_other_email (notmuch_config_t *config,\r
196                                      const char *other_email[],\r
197                                      size_t length);\r
198  \r
199 +notmuch_bool_t\r
200 +debugger_is_active (void);\r
201 +\r
202  #endif\r
203 diff --git a/notmuch-new.c b/notmuch-new.c\r
204 index 43cc4fb..18ba2bd 100644\r
205 --- a/notmuch-new.c\r
206 +++ b/notmuch-new.c\r
207 @@ -272,11 +272,13 @@ add_files (notmuch_database_t *notmuch,\r
208      }\r
209  \r
210      /* Setup our handler for SIGALRM */\r
211 -    memset (&action, 0, sizeof (struct sigaction));\r
212 -    action.sa_handler = handle_sigalrm;\r
213 -    sigemptyset (&action.sa_mask);\r
214 -    action.sa_flags = SA_RESTART;\r
215 -    sigaction (SIGALRM, &action, NULL);\r
216 +    if (! debugger_is_active ()) {\r
217 +       memset (&action, 0, sizeof (struct sigaction));\r
218 +       action.sa_handler = handle_sigalrm;\r
219 +       sigemptyset (&action.sa_mask);\r
220 +       action.sa_flags = SA_RESTART;\r
221 +       sigaction (SIGALRM, &action, NULL);\r
222 +    }\r
223  \r
224      /* Then start a timer to send SIGALRM once per second. */\r
225      timerval.it_interval.tv_sec = 1;\r
226 -- \r
227 1.6.5.3\r
228 \r