44 *
55 * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
66 *
7- * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.98 2008/04/24 14:23:43 mha Exp $
7+ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.99 2008/06/26 01:12:20 momjian Exp $
88 *
99 *-------------------------------------------------------------------------
1010 */
@@ -140,7 +140,6 @@ static void read_post_opts(void);
140140static bool test_postmaster_connection (bool );
141141static bool postmaster_is_alive (pid_t pid );
142142
143- static char def_postopts_file [MAXPGPATH ];
144143static char postopts_file [MAXPGPATH ];
145144static char pid_file [MAXPGPATH ];
146145static char conf_file [MAXPGPATH ];
@@ -575,42 +574,35 @@ unlimit_core_size(void)
575574static void
576575read_post_opts (void )
577576{
578- char * optline = NULL ;
579-
580577if (post_opts == NULL )
581578{
582579char * * optlines ;
583- int len ;
584580
585- optlines = readfile (ctl_command == RESTART_COMMAND ?
586- postopts_file :def_postopts_file );
587- if (optlines == NULL )
581+ post_opts = "" ;/* defatult */
582+ if (ctl_command == RESTART_COMMAND )
588583{
589- if (ctl_command == START_COMMAND || ctl_command == RUN_AS_SERVICE_COMMAND )
590- post_opts = "" ;
591- else
584+ optlines = readfile (postopts_file );
585+ if (optlines == NULL )
592586{
593587write_stderr (_ ("%s: could not read file \"%s\"\n" ),progname ,postopts_file );
594588exit (1 );
595589}
596- }
597- else if (optlines [0 ]== NULL || optlines [1 ]!= NULL )
598- {
599- write_stderr (_ ("%s: option file \"%s\" must have exactly one line\n" ),
600- progname ,ctl_command == RESTART_COMMAND ?
601- postopts_file :def_postopts_file );
602- exit (1 );
603- }
604- else
605- {
606- optline = optlines [0 ];
607- len = strcspn (optline ,"\r\n" );
608- optline [len ]= '\0' ;
609-
610- if (ctl_command == RESTART_COMMAND )
590+ else if (optlines [0 ]== NULL || optlines [1 ]!= NULL )
611591{
592+ write_stderr (_ ("%s: option file \"%s\" must have exactly one line\n" ),
593+ progname ,postopts_file );
594+ exit (1 );
595+ }
596+ else
597+ {
598+ int len ;
599+ char * optline = NULL ;
612600char * arg1 ;
613601
602+ optline = optlines [0 ];
603+ len = strcspn (optline ,"\r\n" );
604+ optline [len ]= '\0' ;
605+
614606arg1 = strchr (optline ,* SYSTEMQUOTE );
615607if (arg1 == NULL || arg1 == optline )
616608post_opts = "" ;
@@ -622,8 +614,6 @@ read_post_opts(void)
622614if (postgres_path != NULL )
623615postgres_path = optline ;
624616}
625- else
626- post_opts = optline ;
627617}
628618}
629619}
@@ -1894,7 +1884,6 @@ main(int argc, char **argv)
18941884
18951885if (pg_data )
18961886{
1897- snprintf (def_postopts_file ,MAXPGPATH , "%s /postmaster .opts .default ",pg_data );
18981887snprintf (postopts_file ,MAXPGPATH , "%s /postmaster .opts ",pg_data );
18991888snprintf (pid_file ,MAXPGPATH , "%s /postmaster .pid ",pg_data );
19001889snprintf (conf_file ,MAXPGPATH , "%s /postgresql .conf ",pg_data );