aboutsummaryrefslogtreecommitdiff
path: root/src/test/regress/pg_regress.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/regress/pg_regress.c')
-rw-r--r--src/test/regress/pg_regress.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index 5daf28a666d..236be9456d9 100644
--- a/src/test/regress/pg_regress.c
+++ b/src/test/regress/pg_regress.c
@@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.23 2006/10/04 00:30:14 momjian Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.24 2007/01/05 16:17:55 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
@@ -24,6 +24,11 @@
#include <signal.h>
#include <unistd.h>
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
#include "getopt_long.h"
#include "pg_config_paths.h"
@@ -122,6 +127,30 @@ psql_command(const char *database, const char *query,...)
the supplied arguments. */
__attribute__((format(printf, 2, 3)));
+/*
+ * allow core files if possible.
+ */
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+static void
+unlimit_core_size(void)
+{
+ struct rlimit lim;
+ getrlimit(RLIMIT_CORE,&lim);
+ if (lim.rlim_max == 0)
+ {
+ fprintf(stderr,
+ _("%s: cannot set core size,: disallowed by hard limit.\n"),
+ progname);
+ return;
+ }
+ else if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
+ {
+ lim.rlim_cur = lim.rlim_max;
+ setrlimit(RLIMIT_CORE,&lim);
+ }
+}
+#endif
+
/*
* Add an item at the end of a stringlist.
@@ -1459,6 +1488,10 @@ main(int argc, char *argv[])
initialize_environment();
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+ unlimit_core_size();
+#endif
+
if (temp_install)
{
/*