mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
As part of the work for making relocatable installs, I have re-factored
all the code that looks for other binaries. I move FindExec into port/exec.c (and renamed it to find_my_binary()). I also added find_other_binary that looks for another binary in the same directory as the calling program, and checks the version string. The only behavior change was that initdb and pg_dump would look in the hard-coded bindir directory if it can't find the requested binary in the same directory as the caller. The new code throws an error. The old behavior seemed too error prone for version mismatches.
This commit is contained in:
@ -10,13 +10,18 @@
|
||||
* must be replaced with recv/send.
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/port/pipe.c,v 1.2 2004/04/19 17:42:59 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/port/pipe.c,v 1.3 2004/05/11 21:57:15 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include <sys/wait.h>
|
||||
|
||||
#define _(x) gettext((x))
|
||||
|
||||
#ifdef WIN32
|
||||
int
|
||||
pgpipe(int handles[2])
|
||||
{
|
||||
@ -63,3 +68,42 @@ int piperead(int s, char* buf, int len)
|
||||
ret = 0;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pclose() plus useful error reporting
|
||||
* Is this necessary? bjm 2004-05-11
|
||||
*/
|
||||
int
|
||||
pclose_check(FILE *stream)
|
||||
{
|
||||
int exitstatus;
|
||||
|
||||
exitstatus = pclose(stream);
|
||||
|
||||
if (exitstatus == 0)
|
||||
return 0; /* all is well */
|
||||
|
||||
if (exitstatus == -1)
|
||||
{
|
||||
/* pclose() itself failed, and hopefully set errno */
|
||||
perror("pclose failed");
|
||||
}
|
||||
else if (WIFEXITED(exitstatus))
|
||||
{
|
||||
fprintf(stderr, _("child process exited with exit code %d\n"),
|
||||
WEXITSTATUS(exitstatus));
|
||||
}
|
||||
else if (WIFSIGNALED(exitstatus))
|
||||
{
|
||||
fprintf(stderr, _("child process was terminated by signal %d\n"),
|
||||
WTERMSIG(exitstatus));
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, _("child process exited with unrecognized status %d\n"),
|
||||
exitstatus);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user