From 15fe829b23ad1871ed0b27d807371cbd37768289 Mon Sep 17 00:00:00 2001
From: Magnus Hagander <magnus@hagander.net>
Date: Thu, 9 Jun 2011 18:18:45 +0200
Subject: [PATCH] Support silent mode for service registrations on win32

Using -s when registering a service will now suppress
the application eventlog entries stating that the service
is starting and started.

MauMau
---
 doc/src/sgml/ref/pg_ctl-ref.sgml | 1 +
 src/bin/pg_ctl/pg_ctl.c          | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
index 5edc167de3..f75e5210d9 100644
--- a/doc/src/sgml/ref/pg_ctl-ref.sgml
+++ b/doc/src/sgml/ref/pg_ctl-ref.sgml
@@ -104,6 +104,7 @@ PostgreSQL documentation
    <arg>-D <replaceable>datadir</replaceable></arg>
    <arg>-w</arg>
    <arg>-t <replaceable>seconds</replaceable></arg>
+   <arg>-s</arg>
    <arg>-o <replaceable>options</replaceable></arg>
   </cmdsynopsis>
 
diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
index dad7e8b79d..7714815b05 100644
--- a/src/bin/pg_ctl/pg_ctl.c
+++ b/src/bin/pg_ctl/pg_ctl.c
@@ -155,6 +155,9 @@ write_eventlog(int level, const char *line)
 {
 	static HANDLE evtHandle = INVALID_HANDLE_VALUE;
 
+	if (silent_mode && level == EVENTLOG_INFORMATION_TYPE)
+		return;
+
 	if (evtHandle == INVALID_HANDLE_VALUE)
 	{
 		evtHandle = RegisterEventSource(NULL, "PostgreSQL");
@@ -1131,6 +1134,9 @@ pgwin32_CommandLine(bool registration)
 		/* concatenate */
 		sprintf(cmdLine + strlen(cmdLine), " -t %d", wait_seconds);
 
+	if (registration && silent_mode)
+		strcat(cmdLine, " -s");
+
 	if (post_opts)
 	{
 		strcat(cmdLine, " ");
-- 
2.49.0