39
39
#include "getopt_long.h"
40
40
#include "miscadmin.h"
41
41
42
- #if defined(__CYGWIN__ )
43
- #include <sys/cygwin.h>
44
- #include <windows.h>
45
- /* Cygwin defines WIN32 in windows.h, but we don't want it. */
46
- #undef WIN32
47
- #endif
48
-
49
42
/* PID can be negative for standalone backend */
50
43
typedef long pgpid_t ;
51
44
@@ -105,7 +98,7 @@ static char backup_file[MAXPGPATH];
105
98
static char recovery_file [MAXPGPATH ];
106
99
static char promote_file [MAXPGPATH ];
107
100
108
- #if defined( WIN32 ) || defined( __CYGWIN__ )
101
+ #ifdef WIN32
109
102
static DWORD pgctl_start_type = SERVICE_AUTO_START ;
110
103
static SERVICE_STATUS status ;
111
104
static SERVICE_STATUS_HANDLE hStatus = (SERVICE_STATUS_HANDLE ) 0 ;
@@ -133,7 +126,7 @@ static void do_kill(pgpid_t pid);
133
126
static void print_msg (const char * msg );
134
127
static void adjust_data_dir (void );
135
128
136
- #if defined( WIN32 ) || defined( __CYGWIN__ )
129
+ #ifdef WIN32
137
130
#if (_MSC_VER >= 1800 )
138
131
#include <versionhelpers.h>
139
132
#else
@@ -165,7 +158,7 @@ static void unlimit_core_size(void);
165
158
#endif
166
159
167
160
168
- #if defined( WIN32 ) || defined( __CYGWIN__ )
161
+ #ifdef WIN32
169
162
static void
170
163
write_eventlog (int level , const char * line )
171
164
{
@@ -207,20 +200,11 @@ write_stderr(const char *fmt,...)
207
200
va_list ap ;
208
201
209
202
va_start (ap , fmt );
210
- #if !defined( WIN32 ) && !defined( __CYGWIN__ )
203
+ #ifndef WIN32
211
204
/* On Unix, we just fprintf to stderr */
212
205
vfprintf (stderr , fmt , ap );
213
206
#else
214
207
215
- /*
216
- * On Cygwin, we don't yet have a reliable mechanism to detect when
217
- * we're being run as a service, so fall back to the old (and broken)
218
- * stderr test.
219
- */
220
- #ifdef __CYGWIN__
221
- #define pgwin32_is_service () (isatty(fileno(stderr)))
222
- #endif
223
-
224
208
/*
225
209
* On Win32, we print to stderr if running on a console, or write to
226
210
* eventlog if running as a service
@@ -718,7 +702,7 @@ test_postmaster_connection(pgpid_t pm_pid, bool do_checkpoint)
718
702
#endif
719
703
720
704
/* No response, or startup still in process; wait */
721
- #if defined( WIN32 )
705
+ #ifdef WIN32
722
706
if (do_checkpoint )
723
707
{
724
708
/*
@@ -1342,7 +1326,7 @@ do_kill(pgpid_t pid)
1342
1326
}
1343
1327
}
1344
1328
1345
- #if defined( WIN32 ) || defined( __CYGWIN__ )
1329
+ #ifdef WIN32
1346
1330
1347
1331
#if (_MSC_VER < 1800 )
1348
1332
static bool
@@ -1408,20 +1392,6 @@ pgwin32_CommandLine(bool registration)
1408
1392
}
1409
1393
}
1410
1394
1411
- #ifdef __CYGWIN__
1412
- /* need to convert to windows path */
1413
- {
1414
- char buf [MAXPGPATH ];
1415
-
1416
- #if CYGWIN_VERSION_DLL_MAJOR >= 1007
1417
- cygwin_conv_path (CCP_POSIX_TO_WIN_A , cmdPath , buf , sizeof (buf ));
1418
- #else
1419
- cygwin_conv_to_full_win32_path (cmdPath , buf );
1420
- #endif
1421
- strcpy (cmdPath , buf );
1422
- }
1423
- #endif
1424
-
1425
1395
/* if path does not end in .exe, append it */
1426
1396
if (strlen (cmdPath ) < 4 ||
1427
1397
pg_strcasecmp (cmdPath + strlen (cmdPath ) - 4 , ".exe" ) != 0 )
@@ -1775,10 +1745,8 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1775
1745
if (!OpenProcessToken (GetCurrentProcess (), TOKEN_ALL_ACCESS , & origToken ))
1776
1746
{
1777
1747
/*
1778
- * Most Windows targets make DWORD a 32-bit unsigned long. Cygwin
1779
- * x86_64, an LP64 target, makes it a 32-bit unsigned int. In code
1780
- * built for Cygwin as well as for native Windows targets, cast DWORD
1781
- * before printing.
1748
+ * Most Windows targets make DWORD a 32-bit unsigned long, but
1749
+ * in case it doesn't cast DWORD before printing.
1782
1750
*/
1783
1751
write_stderr (_ ("%s: could not open process token: error code %lu\n" ),
1784
1752
progname , (unsigned long ) GetLastError ());
@@ -1819,10 +1787,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1819
1787
return 0 ;
1820
1788
}
1821
1789
1822
- #ifndef __CYGWIN__
1823
1790
AddUserToTokenDacl (restrictedToken );
1824
- #endif
1825
-
1826
1791
r = CreateProcessAsUser (restrictedToken , NULL , cmd , NULL , NULL , TRUE, CREATE_SUSPENDED , NULL , NULL , & si , processInfo );
1827
1792
1828
1793
Kernel32Handle = LoadLibrary ("KERNEL32.DLL" );
@@ -1926,7 +1891,7 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION *processInfo, bool as_ser
1926
1891
*/
1927
1892
return r ;
1928
1893
}
1929
- #endif /* defined( WIN32) || defined(__CYGWIN__) */
1894
+ #endif /* WIN32 */
1930
1895
1931
1896
static void
1932
1897
do_advice (void )
@@ -1950,15 +1915,15 @@ do_help(void)
1950
1915
printf (_ (" %s status [-D DATADIR]\n" ), progname );
1951
1916
printf (_ (" %s promote [-D DATADIR] [-s]\n" ), progname );
1952
1917
printf (_ (" %s kill SIGNALNAME PID\n" ), progname );
1953
- #if defined( WIN32 ) || defined( __CYGWIN__ )
1918
+ #ifdef WIN32
1954
1919
printf (_ (" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
1955
1920
" [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n" ), progname );
1956
1921
printf (_ (" %s unregister [-N SERVICENAME]\n" ), progname );
1957
1922
#endif
1958
1923
1959
1924
printf (_ ("\nCommon options:\n" ));
1960
1925
printf (_ (" -D, --pgdata=DATADIR location of the database storage area\n" ));
1961
- #if defined( WIN32 ) || defined( __CYGWIN__ )
1926
+ #ifdef WIN32
1962
1927
printf (_ (" -e SOURCE event source for logging when running as a service\n" ));
1963
1928
#endif
1964
1929
printf (_ (" -s, --silent only print errors, no informational messages\n" ));
@@ -1991,7 +1956,7 @@ do_help(void)
1991
1956
printf (_ ("\nAllowed signal names for kill:\n" ));
1992
1957
printf (" ABRT HUP INT QUIT TERM USR1 USR2\n" );
1993
1958
1994
- #if defined( WIN32 ) || defined( __CYGWIN__ )
1959
+ #ifdef WIN32
1995
1960
printf (_ ("\nOptions for register and unregister:\n" ));
1996
1961
printf (_ (" -N SERVICENAME service name with which to register PostgreSQL server\n" ));
1997
1962
printf (_ (" -P PASSWORD password of account to register PostgreSQL server\n" ));
@@ -2067,7 +2032,7 @@ set_sig(char *signame)
2067
2032
}
2068
2033
2069
2034
2070
- #if defined( WIN32 ) || defined( __CYGWIN__ )
2035
+ #ifdef WIN32
2071
2036
static void
2072
2037
set_starttype (char * starttypeopt )
2073
2038
{
@@ -2167,7 +2132,7 @@ main(int argc, char **argv)
2167
2132
int c ;
2168
2133
pgpid_t killproc = 0 ;
2169
2134
2170
- #if defined( WIN32 ) || defined( __CYGWIN__ )
2135
+ #ifdef WIN32
2171
2136
setvbuf (stderr , NULL , _IONBF , 0 );
2172
2137
#endif
2173
2138
@@ -2280,7 +2245,7 @@ main(int argc, char **argv)
2280
2245
silent_mode = true;
2281
2246
break ;
2282
2247
case 'S' :
2283
- #if defined( WIN32 ) || defined( __CYGWIN__ )
2248
+ #ifdef WIN32
2284
2249
set_starttype (optarg );
2285
2250
#else
2286
2251
write_stderr (_ ("%s: -S option not supported on this platform\n" ),
@@ -2353,7 +2318,7 @@ main(int argc, char **argv)
2353
2318
set_sig (argv [++ optind ]);
2354
2319
killproc = atol (argv [++ optind ]);
2355
2320
}
2356
- #if defined( WIN32 ) || defined( __CYGWIN__ )
2321
+ #ifdef WIN32
2357
2322
else if (strcmp (argv [optind ], "register") == 0 )
2358
2323
ctl_command = REGISTER_COMMAND ;
2359
2324
else if (strcmp (argv [optind ], "unregister ") == 0 )
@@ -2457,7 +2422,7 @@ main(int argc, char **argv)
2457
2422
case KILL_COMMAND :
2458
2423
do_kill (killproc );
2459
2424
break ;
2460
- #if defined( WIN32 ) || defined( __CYGWIN__ )
2425
+ #ifdef WIN32
2461
2426
case REGISTER_COMMAND :
2462
2427
pgwin32_doRegister ();
2463
2428
break ;
0 commit comments