]> granicus.if.org Git - postgresql/commitdiff
Use get_progname() in backend main.c, rather than port-specific hack
authorBruce Momjian <bruce@momjian.us>
Thu, 13 Oct 2005 15:37:14 +0000 (15:37 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 13 Oct 2005 15:37:14 +0000 (15:37 +0000)
that is too fragile.

src/backend/main/main.c
src/port/path.c

index e4f112b42160d38f91e822b9ef188c21aa23e17f..ed1895d839c94318c87b0e87a7e3b514a2ce09ff 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/backend/main/main.c,v 1.94 2004/12/31 21:59:53 pgsql Exp $
+ *       $PostgreSQL: pgsql/src/backend/main/main.c,v 1.95 2005/10/13 15:37:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -50,8 +50,6 @@
 int
 main(int argc, char *argv[])
 {
-       int                     len;
-
 #ifndef WIN32
        struct passwd *pw;
 #endif
@@ -256,13 +254,7 @@ main(int argc, char *argv[])
         * (and possibly first argument) we were called with. The lack of
         * consistency here is historical.
         */
-       len = strlen(argv[0]);
-
-       if ((len >= 10 && strcmp(argv[0] + len - 10, "postmaster") == 0)
-#ifdef WIN32
-         || (len >= 14 && strcmp(argv[0] + len - 14, "postmaster.exe") == 0)
-#endif
-               )
+       if (strcmp(get_progname(argv[0]), "postmaster") == 0)
        {
                /* Called as "postmaster" */
                exit(PostmasterMain(argc, argv));
index bdb6e29adf157ad189c12674f0977fac8b989e58..a1c91a24dddcc26996ea7e30c78fd44320d658fc 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/port/path.c,v 1.59 2005/09/27 17:39:35 tgl Exp $
+ *       $PostgreSQL: pgsql/src/port/path.c,v 1.60 2005/10/13 15:37:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -403,7 +403,7 @@ get_progname(const char *argv0)
        {
                char *progname;
 
-               progname = strdup(nodir_name);
+               progname = strdup(nodir_name);  /* leaks memory, but called only once */
                if (progname == NULL)
                {
                        fprintf(stderr, "%s: out of memory\n", nodir_name);