From 31c453165b5a656044ce1dbce89f5828c1c7e23c Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Tue, 13 Jan 2015 13:12:37 +0100 Subject: 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. --- src/backend/tcop/postgres.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) (limited to 'src/backend/tcop/postgres.c') 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 #include #include -#include #include #include #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. */ @@ -3589,11 +3570,6 @@ PostgresMain(int argc, char *argv[], proc_exit(1); } - /* - * 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. * -- cgit v1.2.3