Skip to content

Commit c55de22

Browse files
committed
Enable service use by Cygwin of pg_ctl.
1 parent 4855d7e commit c55de22

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/bin/pg_ctl/pg_ctl.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.34 2004/10/12 21:54:43 petere Exp $
7+
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.35 2004/10/13 10:35:05 momjian Exp $
88
*
99
*-------------------------------------------------------------------------
1010
*/
@@ -21,6 +21,10 @@
2121
#include "libpq/pqsignal.h"
2222
#include "getopt_long.h"
2323

24+
#if defined(__CYGWIN__)
25+
#include <windows.h>
26+
#endif
27+
2428
#ifndef HAVE_OPTRESET
2529
int optreset;
2630
#endif
@@ -95,7 +99,7 @@ static void do_reload(void);
9599
static void do_status(void);
96100
static void do_kill(pgpid_t pid);
97101

98-
#ifdef WIN32
102+
#if defined(WIN32) || defined(__CYGWIN__)
99103
static bool pgwin32_IsInstalled(SC_HANDLE);
100104
static char *pgwin32_CommandLine(bool);
101105
static void pgwin32_doRegister();
@@ -116,7 +120,7 @@ static char pid_file[MAXPGPATH];
116120
static char conf_file[MAXPGPATH];
117121

118122

119-
#ifdef WIN32
123+
#if defined(WIN32) || defined(__CYGWIN__)
120124
static void
121125
write_eventlog(int level, const char *line)
122126
{
@@ -154,7 +158,7 @@ write_stderr(const char *fmt,...)
154158
va_list ap;
155159

156160
va_start(ap, fmt);
157-
#ifndef WIN32
161+
#if !defined(WIN32) && !defined(__CYGWIN__)
158162
/* On Unix, we just fprintf to stderr */
159163
vfprintf(stderr, fmt, ap);
160164
#else
@@ -318,15 +322,15 @@ start_postmaster(void)
318322
* http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm
319323
*/
320324
if (log_file != NULL)
321-
#ifndef WIN32
325+
#if !defined(WIN32) && !defined(__CYGWIN__)
322326
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
323327
#else
324328
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
325329
#endif
326330
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
327331
DEVNULL, log_file, SYSTEMQUOTE);
328332
else
329-
#ifndef WIN32
333+
#if !defined(WIN32) && !defined(__CYGWIN__)
330334
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
331335
#else
332336
snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s",
@@ -807,7 +811,7 @@ do_kill(pgpid_t pid)
807811
}
808812
}
809813

810-
#ifdef WIN32
814+
#if defined(WIN32) || defined(__CYGWIN__)
811815

812816
static bool
813817
pgwin32_IsInstalled(SC_HANDLE hSCM)
@@ -1085,14 +1089,14 @@ do_help(void)
10851089
printf(_(" %s reload [-D DATADIR] [-s]\n"), progname);
10861090
printf(_(" %s status [-D DATADIR]\n"), progname);
10871091
printf(_(" %s kill SIGNALNAME PROCESSID\n"), progname);
1088-
#ifdef WIN32
1092+
#if defined(WIN32) || defined(__CYGWIN__)
10891093
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR] [-w] [-o \"OPTIONS\"]\n"), progname);
10901094
printf(_(" %s unregister [-N SERVICENAME]\n"), progname);
10911095
#endif
10921096
printf(_("Common options:\n"));
10931097
printf(_(" -D, --pgdata DATADIR location of the database storage area\n"));
10941098
printf(_(" -s, --silent only print errors, no informational messages\n"));
1095-
#ifdef WIN32
1099+
#if defined(WIN32) || defined(__CYGWIN__)
10961100
printf(_(" -N service name with which to register PostgreSQL server\n"));
10971101
printf(_(" -P password of account to register PostgreSQL server\n"));
10981102
printf(_(" -U user name of account to register PostgreSQL server\n"));
@@ -1201,7 +1205,7 @@ main(int argc, char **argv)
12011205
int c;
12021206
pgpid_t killproc = 0;
12031207

1204-
#ifdef WIN32
1208+
#if defined(WIN32) || defined(__CYGWIN__)
12051209
setvbuf(stderr, NULL, _IONBF, 0);
12061210
#endif
12071211

@@ -1348,7 +1352,7 @@ main(int argc, char **argv)
13481352
set_sig(argv[++optind]);
13491353
killproc = atol(argv[++optind]);
13501354
}
1351-
#ifdef WIN32
1355+
#if defined(WIN32) || defined(__CYGWIN__)
13521356
else if (strcmp(argv[optind], "register") == 0)
13531357
ctl_command = REGISTER_COMMAND;
13541358
else if (strcmp(argv[optind], "unregister") == 0)
@@ -1438,7 +1442,7 @@ main(int argc, char **argv)
14381442
case KILL_COMMAND:
14391443
do_kill(killproc);
14401444
break;
1441-
#ifdef WIN32
1445+
#if defined(WIN32) || defined(__CYGWIN__)
14421446
case REGISTER_COMMAND:
14431447
pgwin32_doRegister();
14441448
break;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy