--- src/common/exec.c.orig
+++ src/common/exec.c
@@ -103,45 +103,45 @@
 
 /*
  * find_my_exec -- find an absolute path to a valid executable
  *
  *	argv0 is the name passed on the command line
  *	retpath is the output area (must be of size MAXPGPATH)
  *	Returns 0 if OK, -1 if error.
  *
  * The reason we have to work so hard to find an absolute path is that
  * on some platforms we can't do dynamic loading unless we know the
  * executable's location.  Also, we need a full path not a relative
  * path because we will later change working directory.  Finally, we want
  * a true path not a symlink location, so that we can locate other files
  * that are part of our installation relative to the executable.
  */
 int
 find_my_exec(const char *argv0, char *retpath)
 {
 	char		cwd[MAXPGPATH],
 				test_path[MAXPGPATH];
 	char	   *path;
 
-	if (!getcwd(cwd, MAXPGPATH))
+	if (!is_absolute_path(argv0) && !getcwd(cwd, MAXPGPATH))
 	{
 		log_error(_("could not identify current directory: %s"),
 				  strerror(errno));
 		return -1;
 	}
 
 	/*
 	 * If argv0 contains a separator, then PATH wasn't used.
 	 */
 	if (first_dir_separator(argv0) != NULL)
 	{
 		if (is_absolute_path(argv0))
 			StrNCpy(retpath, argv0, MAXPGPATH);
 		else
 			join_path_components(retpath, cwd, argv0);
 		canonicalize_path(retpath);
 
 		if (validate_exec(retpath) == 0)
 			return resolve_symlinks(retpath);
 
 		log_error(_("invalid binary \"%s\""), retpath);
 		return -1;
@@ -219,44 +219,50 @@
 resolve_symlinks(char *path)
 {
 #ifdef HAVE_READLINK
 	struct stat buf;
 	char		orig_wd[MAXPGPATH],
 				link_buf[MAXPGPATH];
 	char	   *fname;
 
 	/*
 	 * To resolve a symlink properly, we have to chdir into its directory
