*** a/src/bin/pg_ctl/pg_ctl.c --- b/src/bin/pg_ctl/pg_ctl.c *************** *** 1326,1332 **** pgwin32_CommandLine(bool registration) register_servicename); if (pg_config) ! appendPQExpBuffer(cmdLine, " -D \"%s\"", pg_config); if (registration && do_wait) appendPQExpBuffer(cmdLine, " -w"); --- 1326,1344 ---- register_servicename); if (pg_config) ! { ! char dataDir[MAXPGPATH]; ! ! if (get_absolute_path(pg_config, dataDir) != 0) ! { ! write_stderr(_("%s: could not identify current directory\n"), ! progname); ! exit(1); ! } ! ! make_native_path(dataDir); ! appendPQExpBuffer(cmdLine, " -D \"%s\"", dataDir); ! } if (registration && do_wait) appendPQExpBuffer(cmdLine, " -w"); *** a/src/include/port.h --- b/src/include/port.h *************** *** 59,64 **** extern void get_html_path(const char *my_exec_path, char *ret_path); --- 59,65 ---- extern void get_man_path(const char *my_exec_path, char *ret_path); extern bool get_home_path(char *ret_path); extern void get_parent_directory(char *path); + extern int get_absolute_path(char *inpath, char *retpath); /* port/dirmod.c */ extern char **pgfnames(const char *path); *** a/src/port/path.c --- b/src/port/path.c *************** *** 757,759 **** trim_trailing_separator(char *path) --- 757,788 ---- for (p--; p > path && IS_DIR_SEP(*p); p--) *p = '\0'; } + + /* + * get_absolute_path -- get an absolute path to a given path + * + * inpath is the input path for which absolute path required. + * retpath is the output area (must be of size MAXPGPATH) + * Returns 0 if OK, -1 if error. + */ + int + get_absolute_path(char *inpath, char *retpath) + { + /* + * Check if it is already absolute path. + */ + if (is_absolute_path(inpath)) + { + strlcpy(retpath, inpath, MAXPGPATH); + } + else + { + if (!getcwd(retpath, MAXPGPATH)) + return -1; + + join_path_components(retpath, retpath, inpath); + canonicalize_path(retpath); + } + + return 0; + }