*
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.74 2006/10/12 05:14:49 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.75 2007/01/05 16:17:55 adunstan Exp $
*
*-------------------------------------------------------------------------
*/
#include
#include
+#ifdef HAVE_SYS_RESOURCE_H
+#include
+#include
+#endif
+
#include "libpq/pqsignal.h"
#include "getopt_long.h"
static char *register_username = NULL;
static char *register_password = NULL;
static char *argv0 = NULL;
+static bool allow_core_files = false;
static void
write_stderr(const char *fmt,...)
static char pid_file[MAXPGPATH];
static char conf_file[MAXPGPATH];
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+static void unlimit_core_size(void);
+#endif
+
#if defined(WIN32) || defined(__CYGWIN__)
static void
}
+#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)
+ {
+ write_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
+
+
static void
do_start(void)
postgres_path = postmaster_path;
}
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+ if (allow_core_files)
+ unlimit_core_size();
+#endif
+
exitcode = start_postmaster();
if (exitcode != 0)
{
printf(_(" -o OPTIONS command line options to pass to postgres\n"
" (PostgreSQL server executable)\n"));
printf(_(" -p PATH-TO-POSTGRES normally not necessary\n"));
-
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+ printf(_(" -c, --core-files allow postgres to produce core files\n"));
+#else
+ printf(_(" -c, --core-files not applicable on this platform\n"));
+#endif
printf(_("\nOptions for stop or restart:\n"));
printf(_(" -m SHUTDOWN-MODE may be \"smart\", \"fast\", or \"immediate\"\n"));
{"mode", required_argument, NULL, 'm'},
{"pgdata", required_argument, NULL, 'D'},
{"silent", no_argument, NULL, 's'},
+ {"core-files", no_argument, NULL, 'c'},
{NULL, 0, NULL, 0}
};
/* process command-line options */
while (optind < argc)
{
- while ((c = getopt_long(argc, argv, "D:l:m:N:o:p:P:sU:wW", long_options, &option_index)) != -1)
+ while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:sU:wW", long_options, &option_index)) != -1)
{
switch (c)
{
do_wait = false;
wait_set = true;
break;
+ case 'c':
+ allow_core_files = true;
+ break;
default:
/* getopt_long already issued a suitable error message */
do_advice();
* 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 $
*
*-------------------------------------------------------------------------
*/
#include
#include
+#ifdef HAVE_SYS_RESOURCE_H
+#include
+#include
+#endif
+
#include "getopt_long.h"
#include "pg_config_paths.h"
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.
initialize_environment();
+#if defined(HAVE_GETRLIMIT) && defined(RLIMIT_CORE)
+ unlimit_core_size();
+#endif
+
if (temp_install)
{
/*