pg_ctl: WIN32 for CYGWIN also (services)

Reini Urban <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.patches
Message-ID <[email protected]>
I'd like to have this nice new features also :)

Just redefine WIN32 #ifdef __CYGWIN___ or the clean and long way as in 
my patch?
I'm not sure about any dirty side-effects.

Builds fine and works as expected.
(Just tablespace symlinks not yet. Will get to that soon.)


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org
pg_ctl-cygwin.patch (text/plain, 2.4 KB)
--- postgresql-8.0.0cvs/src/bin/pg_ctl/pg_ctl.c.orig	2004-09-02 22:07:50.000000000 +0200
+++ postgresql-8.0.0cvs/src/bin/pg_ctl/pg_ctl.c	2004-10-07 05:29:28.938946400 +0200
@@ -20,6 +20,9 @@
 
 #include "libpq/pqsignal.h"
 #include "getopt_long.h"
+#if defined(__CYGWIN__)
+#include <windows.h>
+#endif
 
 #ifndef HAVE_OPTRESET
 int			optreset;
@@ -95,7 +98,7 @@
 static void do_status(void);
 static void do_kill(pgpid_t pid);
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 static bool pgwin32_IsInstalled(SC_HANDLE);
 static char *pgwin32_CommandLine(bool);
 static void pgwin32_doRegister();
@@ -116,7 +119,7 @@
 static char conf_file[MAXPGPATH];
 
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 static void
 write_eventlog(int level, const char *line)
 {
@@ -154,7 +157,7 @@
 	va_list		ap;
 
 	va_start(ap, fmt);
-#ifndef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 	/* On Unix, we just fprintf to stderr */
 	vfprintf(stderr, fmt, ap);
 #else
@@ -317,7 +320,7 @@
 	 * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
 	 */
 	if (log_file != NULL)
-#ifndef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
 #else
 		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
@@ -325,7 +328,7 @@
 				 SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
 				 DEVNULL, log_file, SYSTEMQUOTE);
 	else
-#ifndef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 		snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
 #else
 		snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
@@ -803,7 +806,7 @@
 	}
 }
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 
 static bool
 pgwin32_IsInstalled(SC_HANDLE hSCM)
@@ -1197,7 +1200,7 @@
 	int			c;
 	pgpid_t		killproc = 0;
 
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 	setvbuf(stderr, NULL, _IONBF, 0);
 #endif
 
@@ -1344,7 +1347,7 @@
 				set_sig(argv[++optind]);
 				killproc = atol(argv[++optind]);
 			}
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 			else if (strcmp(argv[optind], "register") == 0)
 				ctl_command = REGISTER_COMMAND;
 			else if (strcmp(argv[optind], "unregister") == 0)
@@ -1434,7 +1437,7 @@
 		case KILL_COMMAND:
 			do_kill(killproc);
 			break;
-#ifdef WIN32
+#if defined(WIN32) || defined(__CYGWIN__)
 		case REGISTER_COMMAND:
 			pgwin32_doRegister();
 			break;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.