diff --git a/src/configure.in b/src/configure.in
index d043adf619807f948ac4a6371960a18c40b24545..3bcdd89ce7ac9dc54a5f16e560b6bc40966c6fff 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,4 @@
-AC_REVISION("$Id: configure.in,v 1.842 2004/09/26 15:49:02 marcus Exp $")
+AC_REVISION("$Id: configure.in,v 1.843 2004/09/27 21:47:34 mast Exp $")
 AC_INIT(interpret.c)
 AC_CONFIG_HEADER(machine.h)
 
@@ -1429,7 +1429,7 @@ AC_ARG_WITH(mysql, MY_DESCR([--without-mysql],
 			    [disable support for the Mysql database]),
 	    [],[with_mysql=yes])
 AC_ARG_WITH(valgrind, MY_DESCR([--with-valgrind=path],
-	    [Support for running with valgrind]), [
+	    [Support for running with valgrind. Implies --with-cleanup-on-exit.]), [
   if test "x$with_valgrind" = "xyes"; then
     AC_PATH_PROG(with_valgrind, valgrind, no)
     if test "x$with_valgrind" = "xno"; then
@@ -1574,6 +1574,10 @@ else
   VALGRINDARGS="-q --tool=memcheck"
   AC_DEFINE(USE_VALGRIND)
 
+  if test "x$with_cleanup_on_exit" = "x"; then
+    AC_DEFINE(DO_PIKE_CLEANUP)
+  fi
+
   if test "x$with_copt" != "xno"; then
     PIKE_MSG_WARN([--without-copt is advisable when using valgrind!])
   fi
diff --git a/src/global.h b/src/global.h
index e19eaaae2646ff1ea170503b80fbe67a40813178..7ee4e3ef80d5bbb7384c943cee4bea28d2e02906 100644
--- a/src/global.h
+++ b/src/global.h
@@ -2,7 +2,7 @@
 || This file is part of Pike. For copyright information see COPYRIGHT.
 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
 || for more information.
-|| $Id: global.h,v 1.104 2004/09/26 15:14:44 marcus Exp $
+|| $Id: global.h,v 1.105 2004/09/27 21:47:35 mast Exp $
 */
 
 #ifndef GLOBAL_H
@@ -436,8 +436,7 @@ typedef struct p_wchar_p
 #endif
 
 #ifndef DO_PIKE_CLEANUP
-#if defined(PURIFY) || defined(__CHECKER__) ||				\
-  defined(DEBUG_MALLOC) || defined(USE_VALGRIND)
+#if defined(PURIFY) || defined(__CHECKER__) || defined(DEBUG_MALLOC)
 #define DO_PIKE_CLEANUP
 #endif
 #endif