diff --git a/configure b/configure
index ab213a12c1a895d0a9e1074c08e84a79e4267b43..3dd1b152c6cf50f66b9ee3235b9a44323d484ed9 100755
--- a/configure
+++ b/configure
@@ -13075,12 +13075,6 @@ if test "$PORTNAME" = "cygwin"; then
  ;;
 esac
 
-  case " $LIBOBJS " in
-  *" win32security.$ac_objext "* ) ;;
-  *) LIBOBJS="$LIBOBJS win32security.$ac_objext"
- ;;
-esac
-
 fi
 
 ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h>
diff --git a/configure.in b/configure.in
index 41402dfaa49317e66268984608148cbf8bd93708..93984822e47cd8948d4a40b0a9f01256111c01e6 100644
--- a/configure.in
+++ b/configure.in
@@ -1596,7 +1596,6 @@ fi
 # Cygwin needs only a bit of that
 if test "$PORTNAME" = "cygwin"; then
   AC_LIBOBJ(dirmod)
-  AC_LIBOBJ(win32security)
 fi
 
 AC_CHECK_DECLS([sys_siglist], [], [],
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index 28d3cf2a8f9a4250110117674932aa70a320a4dc..919d76459794840bf5a704ae696b700f8e15e5ed 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -212,6 +212,15 @@ write_stderr(const char *fmt,...)
 	vfprintf(stderr, fmt, ap);
 #else
 
+/*
+ * On Cygwin, we don't yet have a reliable mechanism to detect when
+ * we're being run as a service, so fall back to the old (and broken)
+ * stderr test.
+ */
+#ifdef __CYGWIN__
+#define	pgwin32_is_service()	(isatty(fileno(stderr)))
+#endif
+
 	/*
 	 * On Win32, we print to stderr if running on a console, or write to
 	 * eventlog if running as a service