Use get_progname() in backend main.c, rather than port-specific hack
authorBruce Momjian <[email protected]>
Thu, 13 Oct 2005 15:37:14 +0000 (15:37 +0000)
committerBruce Momjian <[email protected]>
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 12a55bbc4c0239eb9434ceeb9595652473662c44..c0c8cadd5a62aefdd9b98880ed7462ebc88b22e0 100644 (file)
@@ -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 b2778c4977e47657d27a30b076c6300c9dde8ab0..ce7d2444f74349a45790363709aed2a7ad4af04f 100644 (file)
@@ -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);