aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/main/main.c6
-rw-r--r--src/backend/postmaster/postmaster.c8
-rw-r--r--src/include/postmaster/postmaster.h3
-rw-r--r--src/port/path.c35
4 files changed, 25 insertions, 27 deletions
diff --git a/src/backend/main/main.c b/src/backend/main/main.c
index abe229c0e15..ba0fdc52d6a 100644
--- a/src/backend/main/main.c
+++ b/src/backend/main/main.c
@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.94.4.1 2006/01/05 00:55:07 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/main/main.c,v 1.94.4.2 2006/02/01 00:47:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -45,7 +45,7 @@
#include "libpq/pqsignal.h"
#endif
-
+const char *progname;
int
main(int argc, char *argv[])
@@ -101,6 +101,8 @@ main(int argc, char *argv[])
#endif
#endif /* NOFIXADE */
+ progname = get_progname(argv[0]);
+
#if defined(WIN32)
{
WSADATA wsaData;
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index bc7e543242d..ae92ee4b2eb 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.443.4.5 2006/01/06 02:58:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.443.4.6 2006/02/01 00:47:02 momjian Exp $
*
* NOTES
*
@@ -168,9 +168,6 @@ char *ListenAddresses;
*/
int ReservedBackends;
-
-static const char *progname = NULL;
-
/* The socket(s) we're listening to. */
#define MAXLISTEN 64
static int ListenSocket[MAXLISTEN];
@@ -375,9 +372,6 @@ PostmasterMain(int argc, char *argv[])
char *userDoption = NULL;
int i;
- /* This will call exit() if strdup() fails. */
- progname = get_progname(argv[0]);
-
MyProcPid = PostmasterPid = getpid();
IsPostmasterEnvironment = true;
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index c5c611eab44..b40d163e990 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.9 2004/12/31 22:03:39 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/postmaster/postmaster.h,v 1.9.4.1 2006/02/01 00:47:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -34,6 +34,7 @@ extern char *rendezvous_name;
extern HANDLE PostmasterHandle;
#endif
+extern const char *progname;
extern int PostmasterMain(int argc, char *argv[]);
extern void ClosePostmasterPorts(bool am_syslogger);
diff --git a/src/port/path.c b/src/port/path.c
index 54c788fbd1b..22c25b10f95 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/port/path.c,v 1.50.4.2 2005/12/23 22:34:33 tgl Exp $
+ * $PostgreSQL: pgsql/src/port/path.c,v 1.50.4.3 2006/02/01 00:47:03 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -302,7 +302,8 @@ canonicalize_path(char *path)
const char *
get_progname(const char *argv0)
{
- const char *nodir_name;
+ const char *nodir_name;
+ const char *progname;
nodir_name = last_dir_separator(argv0);
if (nodir_name)
@@ -310,27 +311,27 @@ get_progname(const char *argv0)
else
nodir_name = skip_drive(argv0);
-#if defined(__CYGWIN__) || defined(WIN32)
- /* strip .exe suffix, regardless of case */
- if (strlen(nodir_name) > sizeof(EXE) - 1 &&
- pg_strcasecmp(nodir_name + strlen(nodir_name)-(sizeof(EXE)-1), EXE) == 0)
+ /*
+ * Make a copy in case argv[0] is modified by ps_status.
+ * Leaks memory, but called only once.
+ */
+ progname = strdup(nodir_name);
+ if (progname == NULL)
{
- char *progname;
+ fprintf(stderr, "%s: out of memory\n", nodir_name);
+ exit(1); /* This could exit the postmaster */
+ }
- progname = strdup(nodir_name);
- if (progname == NULL)
- {
- fprintf(stderr, "%s: out of memory\n", nodir_name);
- exit(1); /* This could exit the postmaster */
- }
+#if defined(__CYGWIN__) || defined(WIN32)
+ /* strip ".exe" suffix, regardless of case */
+ if (strlen(progname) > sizeof(EXE) - 1 &&
+ pg_strcasecmp(progname + strlen(progname) - (sizeof(EXE) - 1), EXE) == 0)
progname[strlen(progname) - (sizeof(EXE) - 1)] = '\0';
- nodir_name = progname;
- }
#endif
- return nodir_name;
+ return progname;
}
-
+
/*
* dir_strcmp: strcmp except any two DIR_SEP characters are considered equal