Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c8702dc

Browse files
committed
Propogate pg_ctl -D to the postmaster for command-line identification.
1 parent 7531d2f commit c8702dc

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/bin/pg_ctl/pg_ctl.c

+17-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.26 2004/08/28 21:01:38 momjian Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.27 2004/08/28 22:04:01 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -67,6 +67,7 @@ static ShutdownMode shutdown_mode = SMART_MODE;
6767
static int sig = SIGTERM; /* default */
6868
static CtlCommand ctl_command = NO_COMMAND;
6969
static char *pg_data = NULL;
70+
static char *pgdata_opt = NULL;
7071
static char *post_opts = NULL;
7172
static const char *progname;
7273
static char *log_file = NULL;
@@ -309,19 +310,20 @@ start_postmaster(void)
309310
*/
310311
if (log_file != NULL)
311312
#ifndef WIN32
312-
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s < \"%s\" >> \"%s\" 2>&1 &%s",
313+
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
313314
#else
314-
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s < \"%s\" >> \"%s\" 2>&1%s",
315+
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
315316
#endif
316-
SYSTEMQUOTE, postgres_path, post_opts, DEVNULL, log_file,
317-
SYSTEMQUOTE);
317+
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
318+
DEVNULL, log_file, SYSTEMQUOTE);
318319
else
319320
#ifndef WIN32
320-
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s < \"%s\" 2>&1 &%s",
321+
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
321322
#else
322-
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s < \"%s\" 2>&1%s",
323+
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
323324
#endif
324-
SYSTEMQUOTE, postgres_path, post_opts, DEVNULL, SYSTEMQUOTE);
325+
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
326+
DEVNULL, SYSTEMQUOTE);
325327

326328
return system(cmd);
327329
}
@@ -494,6 +496,10 @@ do_start(void)
494496
}
495497
}
496498

499+
/* No -D or -D already added during server start */
500+
if (ctl_command == RESTART_COMMAND || pgdata_opt == NULL)
501+
pgdata_opt = "";
502+
497503
if (postgres_path == NULL)
498504
{
499505
char *postmaster_path;
@@ -1210,6 +1216,9 @@ main(int argc, char **argv)
12101216
env_var = xmalloc(len + 8);
12111217
snprintf(env_var, len + 8, "PGDATA=%s", optarg);
12121218
putenv(env_var);
1219+
/* Show -D for easier postmaster 'ps' identification */
1220+
pgdata_opt = xmalloc(len + 7);
1221+
snprintf(pgdata_opt, len + 7, "-D \"%s\" ", optarg);
12131222
break;
12141223
}
12151224
case 'l':

0 commit comments

Comments
 (0)