Skip to content

Commit f375d5d

Browse files
committed
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.
1 parent ccfafb4 commit f375d5d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/test/regress/pg_regress.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.21 2006/09/19 15:36:08 tgl Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.22 2006/09/24 17:10:18 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -615,7 +615,7 @@ psql_command(const char *database, const char *query, ...)
615615
/*
616616
* Spawn a process to execute the given shell command; don't wait for it
617617
*
618-
* Returns the process ID so we can wait for it later
618+
* Returns the process ID (or HANDLE) so we can wait for it later
619619
*/
620620
static PID_TYPE
621621
spawn_process(const char *cmdline)
@@ -1512,7 +1512,7 @@ main(int argc, char *argv[])
15121512
*/
15131513
header(_("starting postmaster"));
15141514
snprintf(buf, sizeof(buf),
1515-
SYSTEMQUOTE "\"%s/postmaster\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
1515+
SYSTEMQUOTE "\"%s/postgres\" -D \"%s/data\" -F%s -c \"listen_addresses=%s\" > \"%s/log/postmaster.log\" 2>&1" SYSTEMQUOTE,
15161516
bindir, temp_install,
15171517
debug ? " -d 5" : "",
15181518
hostname ? hostname : "",
@@ -1541,16 +1541,16 @@ main(int argc, char *argv[])
15411541

15421542
/*
15431543
* Fail immediately if postmaster has exited
1544-
*
1545-
* XXX is there a way to do this on Windows?
15461544
*/
15471545
#ifndef WIN32
15481546
if (kill(postmaster_pid, 0) != 0)
1547+
#else
1548+
if (WaitForSingleObject(postmaster_pid, 0) == WAIT_OBJECT_0)
1549+
#endif
15491550
{
15501551
fprintf(stderr, _("\n%s: postmaster failed\nExamine %s/log/postmaster.log for the reason\n"), progname, outputdir);
15511552
exit_nicely(2);
15521553
}
1553-
#endif
15541554

15551555
pg_usleep(1000000L);
15561556
}
@@ -1563,14 +1563,16 @@ main(int argc, char *argv[])
15631563
* in startup. Try to kill it ungracefully rather than leaving
15641564
* a stuck postmaster that might interfere with subsequent test
15651565
* attempts.
1566-
*
1567-
* XXX is there a way to do this on Windows?
15681566
*/
15691567
#ifndef WIN32
15701568
if (kill(postmaster_pid, SIGKILL) != 0 &&
15711569
errno != ESRCH)
15721570
fprintf(stderr, _("\n%s: could not kill failed postmaster: %s\n"),
15731571
progname, strerror(errno));
1572+
#else
1573+
if (TerminateProcess(postmaster_pid, 255) == 0)
1574+
fprintf(stderr, _("\n%s: could not kill failed postmaster: %lu\n"),
1575+
progname, GetLastError());
15741576
#endif
15751577

15761578
exit_nicely(2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy