Skip to content

Commit 32e6c2a

Browse files
committed
Use get_progname() in backend main.c, rather than port-specific hack
that is too fragile.
1 parent 203015e commit 32e6c2a

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

src/backend/main/main.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.94 2004/12/31 21:59:53 pgsql Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.95 2005/10/13 15:37:14 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -50,8 +50,6 @@
5050
int
5151
main(int argc, char *argv[])
5252
{
53-
int len;
54-
5553
#ifndef WIN32
5654
struct passwd *pw;
5755
#endif
@@ -256,13 +254,7 @@ main(int argc, char *argv[])
256254
* (and possibly first argument) we were called with. The lack of
257255
* consistency here is historical.
258256
*/
259-
len = strlen(argv[0]);
260-
261-
if ((len >= 10 && strcmp(argv[0] + len - 10, "postmaster") == 0)
262-
#ifdef WIN32
263-
|| (len >= 14 && strcmp(argv[0] + len - 14, "postmaster.exe") == 0)
264-
#endif
265-
)
257+
if (strcmp(get_progname(argv[0]), "postmaster") == 0)
266258
{
267259
/* Called as "postmaster" */
268260
exit(PostmasterMain(argc, argv));

src/port/path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.59 2005/09/27 17:39:35 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.60 2005/10/13 15:37:14 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -403,7 +403,7 @@ get_progname(const char *argv0)
403403
{
404404
char *progname;
405405

406-
progname = strdup(nodir_name);
406+
progname = strdup(nodir_name); /* leaks memory, but called only once */
407407
if (progname == NULL)
408408
{
409409
fprintf(stderr, "%s: out of memory\n", nodir_name);

0 commit comments

Comments
 (0)