Re: pg_ctl: WIN32 for CYGWIN also (services)

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Reini Urban <rurban(at)x-ray(dot)at>
Cc: pgsql-patches <pgsql-patches(at)postgresql(dot)org>, pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: pg_ctl: WIN32 for CYGWIN also (services)
Date: 2004-10-13 10:36:22
Message-ID: 200410131036.i9DAaMF20115@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32 pgsql-patches


I have applied the attached patch which will allow service use on Cygwin
using pg_ctl. A few of your #ifndef changes were backwards so you might
want to test the attached version to make sure it still works on Cygwin.

---------------------------------------------------------------------------

Reini Urban wrote:
> 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.)

> --- 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;

>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 6.1 KB

In response to

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Dave Page 2004-10-13 11:59:42 Re: [pgsql-hackers-win32] Static build of libpq fails
Previous Message Bruce Momjian 2004-10-13 10:21:08 Re: more dirmod CYGWIN

Browse pgsql-patches by date

  From Date Subject
Next Message Dave Page 2004-10-13 11:59:42 Re: [pgsql-hackers-win32] Static build of libpq fails
Previous Message Bruce Momjian 2004-10-13 10:21:08 Re: more dirmod CYGWIN