diff options
author | Andres Freund <andres@anarazel.de> | 2015-01-13 13:12:37 +0100 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2015-01-14 00:33:14 +0100 |
commit | 31c453165b5a656044ce1dbce89f5828c1c7e23c (patch) | |
tree | ccf0a682b390361d581a7116d6244d7feb80cd45 /src/backend/bootstrap/bootstrap.c | |
parent | 2be82dcf17a18511df5153bcafe67a9c1387be1e (diff) | |
download | postgresql-31c453165b5a656044ce1dbce89f5828c1c7e23c.tar.gz postgresql-31c453165b5a656044ce1dbce89f5828c1c7e23c.zip |
Commonalize process startup code.
Move common code, that was duplicated in every postmaster child/every
standalone process, into two functions in miscinit.c. Not only does
that already result in a fair amount of net code reduction but it also
makes it much easier to remove more duplication in the future. The
prime motivation wasn't code deduplication though, but easier addition
of new common code.
Diffstat (limited to 'src/backend/bootstrap/bootstrap.c')
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index d33c683a4ee..57a1c99d61c 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -14,7 +14,6 @@ */ #include "postgres.h" -#include <time.h> #include <unistd.h> #include <signal.h> @@ -191,19 +190,11 @@ AuxiliaryProcessMain(int argc, char *argv[]) char *userDoption = NULL; /* - * initialize globals + * Initialize process environment (already done if under postmaster, but + * not if standalone). */ - MyProcPid = getpid(); - - MyStartTime = time(NULL); - - /* Compute paths, if we didn't inherit them from postmaster */ - if (my_exec_path[0] == '\0') - { - if (find_my_exec(progname, my_exec_path) < 0) - elog(FATAL, "%s: could not locate my own executable path", - progname); - } + if (!IsUnderPostmaster) + InitStandaloneProcess(argv[0]); /* * process command arguments @@ -516,15 +507,6 @@ bootstrap_signals(void) if (IsUnderPostmaster) { /* - * If possible, make this process a group leader, so that the - * postmaster can signal any child processes too. - */ -#ifdef HAVE_SETSID - if (setsid() < 0) - elog(FATAL, "setsid() failed: %m"); -#endif - - /* * Properly accept or ignore signals the postmaster might send us */ pqsignal(SIGHUP, SIG_IGN); |