|
58 | 58 | * Error Reporting:
|
59 | 59 | * Use write_stderr() only for reporting "interactive" errors
|
60 | 60 | * (essentially, bogus arguments on the command line). Once the
|
61 |
| - * postmaster is launched, use ereport(). In particular, don't use |
62 |
| - * write_stderr() for anything that occurs after pmdaemonize. |
| 61 | + * postmaster is launched, use ereport(). |
63 | 62 | *
|
64 | 63 | *-------------------------------------------------------------------------
|
65 | 64 | */
|
@@ -192,7 +191,6 @@ static int SendStop = false;
|
192 | 191 |
|
193 | 192 | /* still more option variables */
|
194 | 193 | bool EnableSSL = false;
|
195 |
| -bool SilentMode = false; /* silent_mode */ |
196 | 194 |
|
197 | 195 | int PreAuthDelay = 0;
|
198 | 196 | int AuthenticationTimeout = 60;
|
@@ -326,7 +324,6 @@ static DNSServiceRef bonjour_sdref = NULL;
|
326 | 324 | */
|
327 | 325 | static void getInstallationPaths(const char *argv0);
|
328 | 326 | static void checkDataDir(void);
|
329 |
| -static void pmdaemonize(void); |
330 | 327 | static Port *ConnCreate(int serverFd);
|
331 | 328 | static void ConnFree(Port *port);
|
332 | 329 | static void reset_shared(int port);
|
@@ -777,15 +774,6 @@ PostmasterMain(int argc, char *argv[])
|
777 | 774 | (errmsg_internal("-----------------------------------------")));
|
778 | 775 | }
|
779 | 776 |
|
780 |
| - /* |
781 |
| - * Fork away from controlling terminal, if silent_mode specified. |
782 |
| - * |
783 |
| - * Must do this before we grab any interlock files, else the interlocks |
784 |
| - * will show the wrong PID. |
785 |
| - */ |
786 |
| - if (SilentMode) |
787 |
| - pmdaemonize(); |
788 |
| - |
789 | 777 | /*
|
790 | 778 | * Create lockfile for data directory.
|
791 | 779 | *
|
@@ -1270,105 +1258,6 @@ checkDataDir(void)
|
1270 | 1258 | FreeFile(fp);
|
1271 | 1259 | }
|
1272 | 1260 |
|
1273 |
| - |
1274 |
| -/* |
1275 |
| - * Fork away from the controlling terminal (silent_mode option) |
1276 |
| - * |
1277 |
| - * Since this requires disconnecting from stdin/stdout/stderr (in case they're |
1278 |
| - * linked to the terminal), we re-point stdin to /dev/null and stdout/stderr |
1279 |
| - * to "postmaster.log" in the data directory, where we're already chdir'd. |
1280 |
| - */ |
1281 |
| -static void |
1282 |
| -pmdaemonize(void) |
1283 |
| -{ |
1284 |
| -#ifndef WIN32 |
1285 |
| - const char *pmlogname = "postmaster.log"; |
1286 |
| - int dvnull; |
1287 |
| - int pmlog; |
1288 |
| - pid_t pid; |
1289 |
| - int res; |
1290 |
| - |
1291 |
| - /* |
1292 |
| - * Make sure we can open the files we're going to redirect to. If this |
1293 |
| - * fails, we want to complain before disconnecting. Mention the full path |
1294 |
| - * of the logfile in the error message, even though we address it by |
1295 |
| - * relative path. |
1296 |
| - */ |
1297 |
| - dvnull = open(DEVNULL, O_RDONLY, 0); |
1298 |
| - if (dvnull < 0) |
1299 |
| - { |
1300 |
| - write_stderr("%s: could not open file \"%s\": %s\n", |
1301 |
| - progname, DEVNULL, strerror(errno)); |
1302 |
| - ExitPostmaster(1); |
1303 |
| - } |
1304 |
| - pmlog = open(pmlogname, O_CREAT | O_WRONLY | O_APPEND, S_IRUSR | S_IWUSR); |
1305 |
| - if (pmlog < 0) |
1306 |
| - { |
1307 |
| - write_stderr("%s: could not open log file \"%s/%s\": %s\n", |
1308 |
| - progname, DataDir, pmlogname, strerror(errno)); |
1309 |
| - ExitPostmaster(1); |
1310 |
| - } |
1311 |
| - |
1312 |
| - /* |
1313 |
| - * Okay to fork. |
1314 |
| - */ |
1315 |
| - pid = fork_process(); |
1316 |
| - if (pid == (pid_t) -1) |
1317 |
| - { |
1318 |
| - write_stderr("%s: could not fork background process: %s\n", |
1319 |
| - progname, strerror(errno)); |
1320 |
| - ExitPostmaster(1); |
1321 |
| - } |
1322 |
| - else if (pid) |
1323 |
| - { /* parent */ |
1324 |
| - /* Parent should just exit, without doing any atexit cleanup */ |
1325 |
| - _exit(0); |
1326 |
| - } |
1327 |
| - |
1328 |
| - MyProcPid = PostmasterPid = getpid(); /* reset PID vars to child */ |
1329 |
| - |
1330 |
| - MyStartTime = time(NULL); |
1331 |
| - |
1332 |
| - /* |
1333 |
| - * Some systems use setsid() to dissociate from the TTY's process group, |
1334 |
| - * while on others it depends on stdin/stdout/stderr. Do both if |
1335 |
| - * possible. |
1336 |
| - */ |
1337 |
| -#ifdef HAVE_SETSID |
1338 |
| - if (setsid() < 0) |
1339 |
| - { |
1340 |
| - write_stderr("%s: could not dissociate from controlling TTY: %s\n", |
1341 |
| - progname, strerror(errno)); |
1342 |
| - ExitPostmaster(1); |
1343 |
| - } |
1344 |
| -#endif |
1345 |
| - |
1346 |
| - /* |
1347 |
| - * Reassociate stdin/stdout/stderr. fork_process() cleared any pending |
1348 |
| - * output, so this should be safe. The only plausible error is EINTR, |
1349 |
| - * which just means we should retry. |
1350 |
| - */ |
1351 |
| - do |
1352 |
| - { |
1353 |
| - res = dup2(dvnull, 0); |
1354 |
| - } while (res < 0 && errno == EINTR); |
1355 |
| - close(dvnull); |
1356 |
| - do |
1357 |
| - { |
1358 |
| - res = dup2(pmlog, 1); |
1359 |
| - } while (res < 0 && errno == EINTR); |
1360 |
| - do |
1361 |
| - { |
1362 |
| - res = dup2(pmlog, 2); |
1363 |
| - } while (res < 0 && errno == EINTR); |
1364 |
| - close(pmlog); |
1365 |
| -#else /* WIN32 */ |
1366 |
| - /* not supported */ |
1367 |
| - elog(FATAL, "silent_mode is not supported under Windows"); |
1368 |
| -#endif /* WIN32 */ |
1369 |
| -} |
1370 |
| - |
1371 |
| - |
1372 | 1261 | /*
|
1373 | 1262 | * Main idle loop of postmaster
|
1374 | 1263 | */
|
|
0 commit comments