From f375d5d6f95fbcc3a98e9853cf597fbdd06d65e0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 24 Sep 2006 17:10:18 +0000 Subject: [PATCH] Cause pg_regress to invoke the temporary postmaster as 'postgres' not 'postmaster', so as not to depend on the existence of the postmaster symlink. Also, implement postmaster-still-alive and postmaster-kill operations for Windows, per Magnus. --- src/test/regress/pg_regress.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 89cd7a6113..de70348815 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.21 2006/09/19 15:36:08 tgl Exp $ + * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.22 2006/09/24 17:10:18 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -615,7 +615,7 @@ psql_command(const char *database, const char *query, ...) /* * Spawn a process to execute the given shell command; don't wait for it * - * Returns the process ID so we can wait for it later + * Returns the process ID (or HANDLE) so we can wait for it later */ static PID_TYPE spawn_process(const char *cmdline) @@ -1512,7 +1512,7 @@ main(int argc, char *argv[]) */ header(_("starting postmaster")); snprintf(buf, sizeof(buf), - SYSTEMQUOTE "\"%s/postmaster\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE, + SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE, bindir, temp_install, debug ? " -d 5" : "", hostname ? hostname : "", @@ -1541,16 +1541,16 @@ main(int argc, char *argv[]) /* * Fail immediately if postmaster has exited - * - * XXX is there a way to do this on Windows? */ #ifndef WIN32 if (kill(postmaster_pid, 0) != 0) +#else + if (WaitForSingleObject(postmaster_pid, 0) == WAIT_OBJECT_0) +#endif { fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir); exit_nicely(2); } -#endif pg_usleep(1000000L); } @@ -1563,14 +1563,16 @@ main(int argc, char *argv[]) * in startup. Try to kill it ungracefully rather than leaving * a stuck postmaster that might interfere with subsequent test * attempts. - * - * XXX is there a way to do this on Windows? */ #ifndef WIN32 if (kill(postmaster_pid, SIGKILL) != 0 && errno != ESRCH) fprintf(stderr, _("\n%s: could not kill failed postmaster: %s\n"), progname, strerror(errno)); +#else + if (TerminateProcess(postmaster_pid, 255) == 0) + fprintf(stderr, _("\n%s: could not kill failed postmaster: %lu\n"), + progname, GetLastError()); #endif exit_nicely(2);