diff -rpcd a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c *** a/src/bin/pg_ctl/pg_ctl.c Mon Dec 2 09:17:05 2013 --- b/src/bin/pg_ctl/pg_ctl.c Wed Dec 25 16:31:10 2013 *************** do_stop(void) *** 907,913 **** for (cnt = 0; cnt < wait_seconds; cnt++) { ! if ((pid = get_pgpid()) != 0) { print_msg("."); pg_usleep(1000000); /* 1 sec */ --- 907,913 ---- for (cnt = 0; cnt < wait_seconds; cnt++) { ! if (postmaster_is_alive((pid_t) pid)) { print_msg("."); pg_usleep(1000000); /* 1 sec */ *************** do_stop(void) *** 916,922 **** break; } ! if (pid != 0) /* pid file still exists */ { print_msg(_(" failed\n")); --- 916,922 ---- break; } ! if (postmaster_is_alive((pid_t) pid)) { print_msg(_(" failed\n")); *************** do_restart(void) *** 997,1003 **** for (cnt = 0; cnt < wait_seconds; cnt++) { ! if ((pid = get_pgpid()) != 0) { print_msg("."); pg_usleep(1000000); /* 1 sec */ --- 997,1003 ---- for (cnt = 0; cnt < wait_seconds; cnt++) { ! if (postmaster_is_alive((pid_t) pid)) { print_msg("."); pg_usleep(1000000); /* 1 sec */ *************** do_restart(void) *** 1006,1012 **** break; } ! if (pid != 0) /* pid file still exists */ { print_msg(_(" failed\n")); --- 1006,1012 ---- break; } ! if (postmaster_is_alive((pid_t) pid)) { print_msg(_(" failed\n")); diff -rpcd a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c *** a/src/test/regress/pg_regress.c Mon Dec 2 09:17:04 2013 --- b/src/test/regress/pg_regress.c Wed Dec 25 16:29:24 2013 *************** stop_postmaster(void) *** 284,301 **** --- 284,311 ---- { if (postmaster_running) { + #if defined(WIN32) || defined(__CYGWIN__) /* We use pg_ctl to issue the kill and wait for stop */ char buf[MAXPGPATH * 2]; + #endif int r; /* On Windows, system() seems not to force fflush, so... */ fflush(stdout); fflush(stderr); + #if defined(WIN32) || defined(__CYGWIN__) snprintf(buf, sizeof(buf), SYSTEMQUOTE "\"%s/pg_ctl\" stop -D \"%s/data\" -s -m fast" SYSTEMQUOTE, bindir, temp_install); r = system(buf); + #else + /* On UNIX/Linux, pg_ctl times out waiting for a defunct postgres. */ + if (kill(postmaster_pid, SIGINT) != 0) + fprintf(stderr, _("\n%s: could not kill postmaster: %s\n"), + progname, strerror(errno)); + (void) waitpid((pid_t) postmaster_pid, &r, 0); + #endif if (r != 0) { fprintf(stderr, _("\n%s: could not stop postmaster: exit code was %d\n"),