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/tcop/postgres.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/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index c321236bbbb..f805368899a 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -22,7 +22,6 @@ #include <fcntl.h> #include <limits.h> #include <signal.h> -#include <time.h> #include <unistd.h> #include <sys/socket.h> #ifdef HAVE_SYS_SELECT_H @@ -3536,30 +3535,12 @@ PostgresMain(int argc, char *argv[], sigjmp_buf local_sigjmp_buf; volatile bool send_ready_for_query = true; - /* - * Initialize globals (already done if under postmaster, but not if - * standalone). - */ + /* Initialize startup process environment if necessary. */ if (!IsUnderPostmaster) - { - MyProcPid = getpid(); - - MyStartTime = time(NULL); - } + InitStandaloneProcess(argv[0]); SetProcessingMode(InitProcessing); - /* Compute paths, if we didn't inherit them from postmaster */ - if (my_exec_path[0] == '\0') - { - if (find_my_exec(argv[0], my_exec_path) < 0) - elog(FATAL, "%s: could not locate my own executable path", - argv[0]); - } - - if (pkglib_path[0] == '\0') - get_pkglib_path(my_exec_path, pkglib_path); - /* * Set default values for command-line options. */ @@ -3590,11 +3571,6 @@ PostgresMain(int argc, char *argv[], } /* - * You might expect to see a setsid() call here, but it's not needed, - * because if we are under a postmaster then BackendInitialize() did it. - */ - - /* * Set up signal handlers and masks. * * Note that postmaster blocked all signals before forking child process, |