errors=$((errors + 1))
fi
+if pkg-config --modversion valgrind > /dev/null 2>&1; then
+ echo "Checking for valgrind development files... Yes."
+ have_valgrind=-DHAVE_VALGRIND
+else
+ echo "Checking for valgrind development files... No."
+ have_valgrind=
+fi
+
if [ $errors -gt 0 ]; then
cat <<EOF
EOF
exit 1
-else
+fi
+
cat <<EOF
All required packages were found. You may now run the following
sudo make install
EOF
- exit 0
-fi
-cat <<EOF
+
+# construct the Makefile.config
+cat > Makefile.config <<EOF
+prefix = /usr/local
+bash_completion_dir = /etc/bash_completion.d
+CFLAGS += ${have_valgrind}
+EOF
--- /dev/null
+/* debugger.c - Some debugger utilities for the notmuch mail library
+ *
+ * Copyright © 2009 Chris Wilson
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/ .
+ *
+ * Author: Chris Wilson <chris@chris-wilson.co.uk>
+ */
+
+#include "notmuch-client.h"
+
+#include <libgen.h>
+
+#if HAVE_VALGRIND
+#include <valgrind.h>
+#else
+#define RUNNING_ON_VALGRIND 0
+#endif
+
+notmuch_bool_t
+debugger_is_active (void)
+{
+ char buf[1024];
+
+ if (RUNNING_ON_VALGRIND)
+ return TRUE;
+
+ sprintf (buf, "/proc/%d/exe", getppid ());
+ if (readlink (buf, buf, sizeof (buf)) != -1 &&
+ strncmp (basename (buf), "gdb", 3) == 0)
+ {
+ return TRUE;
+ }
+
+ return FALSE;
+}
notmuch_status_t status;
struct sigaction action;
struct itimerval timerval;
+ notmuch_bool_t timer_is_active = FALSE;
if (stat (path, &st)) {
fprintf (stderr, "Error reading directory %s: %s\n",
}
/* Setup our handler for SIGALRM */
- memset (&action, 0, sizeof (struct sigaction));
- action.sa_handler = handle_sigalrm;
- sigemptyset (&action.sa_mask);
- action.sa_flags = SA_RESTART;
- sigaction (SIGALRM, &action, NULL);
-
- /* Then start a timer to send SIGALRM once per second. */
- timerval.it_interval.tv_sec = 1;
- timerval.it_interval.tv_usec = 0;
- timerval.it_value.tv_sec = 1;
- timerval.it_value.tv_usec = 0;
- setitimer (ITIMER_REAL, &timerval, NULL);
+ if (! debugger_is_active ()) {
+ memset (&action, 0, sizeof (struct sigaction));
+ action.sa_handler = handle_sigalrm;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = SA_RESTART;
+ sigaction (SIGALRM, &action, NULL);
+
+ /* Then start a timer to send SIGALRM once per second. */
+ timerval.it_interval.tv_sec = 1;
+ timerval.it_interval.tv_usec = 0;
+ timerval.it_value.tv_sec = 1;
+ timerval.it_value.tv_usec = 0;
+ setitimer (ITIMER_REAL, &timerval, NULL);
+
+ timer_is_active = TRUE;
+ }
status = add_files_recursive (notmuch, path, &st, state);
/* Now stop the timer. */
- timerval.it_interval.tv_sec = 0;
- timerval.it_interval.tv_usec = 0;
- timerval.it_value.tv_sec = 0;
- timerval.it_value.tv_usec = 0;
- setitimer (ITIMER_REAL, &timerval, NULL);
-
- /* And disable the signal handler. */
- action.sa_handler = SIG_IGN;
- sigaction (SIGALRM, &action, NULL);
+ if (timer_is_active) {
+ timerval.it_interval.tv_sec = 0;
+ timerval.it_interval.tv_usec = 0;
+ timerval.it_value.tv_sec = 0;
+ timerval.it_value.tv_usec = 0;
+ setitimer (ITIMER_REAL, &timerval, NULL);
+
+ /* And disable the signal handler. */
+ action.sa_handler = SIG_IGN;
+ sigaction (SIGALRM, &action, NULL);
+ }
return status;
}