Fix for log messages from child processes printing the main process's PID 
authorMuhammad Usama <m.usama@HighGo.ca>
Thu, 2 Jul 2020 18:05:30 +0000 (23:05 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Thu, 2 Jul 2020 18:07:57 +0000 (23:07 +0500)
The issue was caused by my log collector commit. And the reason was: as part of
the log collector implementation, I added a new global variable myProcPid to hold
to the process PID so that we can avoid calling getpid() function every time
during the construction of the log message.

The change was meant to increase the performance but unfortunately I missed
setting the myProcPid variable after fork() at one of the places.
(After forking the pgpool child process).

So to make sure we can avoid such mistakes in the future, I also did a little bit
of refactoring as part of this fix and created a new function that sets all
process-related global variables (process_application_name, myProcPid and
processType) so that we have a single place to add/modify such stuff.

Apart from that, I have made a few changes in functions for setting the
process_application_name and moved them to pool_globasl.c from pgpool_main.c 

19 files changed:
src/include/pool.h
src/main/main.c
src/main/pgpool_logger.c
src/main/pgpool_main.c
src/main/pool_globals.c
src/pcp_con/pcp_child.c
src/protocol/child.c
src/tools/pgenc/Makefile.am
src/tools/pgenc/Makefile.in
src/tools/pgmd5/Makefile.am
src/tools/pgmd5/Makefile.in
src/tools/watchdog/Makefile.am
src/tools/watchdog/Makefile.in
src/watchdog/watchdog.c
src/watchdog/wd_escalation.c
src/watchdog/wd_heartbeat.c
src/watchdog/wd_if.c
src/watchdog/wd_lifecheck.c
src/watchdog/wd_ping.c

index 7f395e03356f3a1bc71e1f055c8fdc48d380d5c5..c3ff2ecc38e3fccc71804431fd00a01d6154710b 100644 (file)
@@ -540,6 +540,14 @@ extern pid_t mypid;                                /* parent pid */
 extern pid_t myProcPid;                        /* process pid */
 extern ProcessType processType;
 extern ProcessState processState;
+extern void set_application_name(ProcessType ptype);
+extern void set_application_name_with_string(char *string);
+extern void set_application_name_with_suffix(ProcessType ptype, int suffix);
+extern char *get_application_name(void);
+extern char *get_application_name_for_procees(ProcessType ptype);
+
+void SetProcessGlobalVaraibles(ProcessType pType);
+
 extern volatile SI_ManageInfo *si_manage_info;
 extern volatile sig_atomic_t sigusr2_received;
 
@@ -613,10 +621,6 @@ extern POOL_NODE_STATUS * verify_backend_node_status(POOL_CONNECTION_POOL_SLOT *
 extern POOL_NODE_STATUS * pool_get_node_status(void);
 extern void pool_set_backend_status_changed_time(int backend_id);
 extern int     get_next_master_node(void);
-extern void set_application_name(ProcessType ptype);
-extern void set_application_name_with_string(char *string);
-extern void set_application_name_with_suffix(ProcessType ptype, int suffix);
-extern char *get_application_name(void);
 
 
 
index 0f79e7e567ded9301a3ea08c344127ddf9d0deca..c463b0f3ef44a870bf4d33b5c412d9b82342a861 100644 (file)
@@ -222,7 +222,8 @@ main(int argc, char **argv)
        hba_file = make_absolute_path(hba_file_path, base_dir);
 
        mypid = getpid();
-       myProcPid = mypid;
+       SetProcessGlobalVaraibles(PT_MAIN);
+
 
        pool_init_config();
 
@@ -479,7 +480,7 @@ daemonize(void)
 #endif
 
        mypid = getpid();
-       myProcPid = mypid;
+       SetProcessGlobalVaraibles(PT_MAIN);
        write_pid_file();
        if (chdir("/"))
                ereport(WARNING,
index 0e6b56cdb665cc4a765f030004ed6157f0c4400b..40d238e59dab4b3d4ce15fceead11a40007f947e 100644 (file)
@@ -525,8 +525,7 @@ SysLogger_Start(void)
 
                case 0:
                        on_exit_reset();
-                       myProcPid = getpid();
-                       processType = PT_LOGGER;
+                       SetProcessGlobalVaraibles(PT_LOGGER);
                        /* do the work */
                        SysLoggerMain(0, NULL);
                        break;
index 86ef9b16bedfb73afe60d0bdbf296d8df36b2a1c..0fe558b20a907e3974d61ef1fcdd85ca1130d4a3 100644 (file)
@@ -239,9 +239,6 @@ PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
        /* For PostmasterRandom */
        gettimeofday(&random_start_time, NULL);
 
-       /* Set the process type variable */
-       processType = PT_MAIN;
-       set_application_name(processType);
        processState = INITIALIZING;
 
        /*
@@ -616,13 +613,11 @@ pcp_fork_a_child(int unix_fd, int inet_fd, char *pcp_conf_file)
        if (pid == 0)
        {
                on_exit_reset();
+               SetProcessGlobalVaraibles(PT_PCP);
 
                close(pipe_fds[0]);
                close(pipe_fds[1]);
 
-               /* Set the process type variable */
-               processType = PT_PCP;
-               myProcPid = getpid();
                /* call PCP child main */
                POOL_SETMASK(&UnBlockSig);
                health_check_timer_expired = 0;
@@ -666,8 +661,7 @@ fork_a_child(int *fds, int id)
                        close(pipe_fds[1]);
                }
 
-               /* Set the process type variable */
-               processType = PT_CHILD;
+               SetProcessGlobalVaraibles(PT_CHILD);
 
                /* call child main */
                POOL_SETMASK(&UnBlockSig);
@@ -714,10 +708,7 @@ worker_fork_a_child(ProcessType type, void (*func) (), void *params)
                        close(pipe_fds[1]);
                }
 
-               /* Set the process type variable */
-               processType = type;
-               myProcPid = getpid();
-               set_application_name(type);
+               SetProcessGlobalVaraibles(type);
 
                /* call child main */
                POOL_SETMASK(&UnBlockSig);
@@ -3251,8 +3242,7 @@ fork_follow_child(int old_master, int new_primary, int old_primary)
        if (pid == 0)
        {
                on_exit_reset();
-               processType = PT_FOLLOWCHILD;
-               myProcPid = getpid();
+               SetProcessGlobalVaraibles(PT_FOLLOWCHILD);
                ereport(LOG,
                                (errmsg("start triggering follow command.")));
                for (i = 0; i < pool_config->backend_desc->num_backends; i++)
@@ -4156,82 +4146,3 @@ pool_set_backend_status_changed_time(int backend_id)
        tval = time(NULL);
        BACKEND_INFO(backend_id).status_changed_time = tval;
 }
-
-/*
- * Application name
- */
-static char    *process_application_name = "main";
-
-/*
- * Fixed application names. ordered by ProcessType.
- */
-char   *application_names[] = {"main",
-                                                               "child",
-                                                               "sr_check_worker",
-                                                               "heart_beat_sender",
-                                                               "heart_beat_receiver",
-                                                               "watchdog",
-                                                               "life_check",
-                                                               "follow_child",
-                                                               "watchdog_utility",
-                                                               "pcp_main",
-                                                               "pcp_child",
-                                                               "health_check"
-};
-
-/*
- * Set application name by ProcessType
- */
-void
-set_application_name(ProcessType ptype)
-{
-       if (ptype < 0 || ptype >= PT_LAST_PTYPE)
-       {
-               ereport(ERROR,
-                               (errmsg("failed to set application name. process type: %d", ptype)));
-       }
-
-       process_application_name = application_names[ptype];
-
-       return;
-}
-
-/*
- * Set application name with arbitrary string. The storage for the string must
- * be persistent at least in the session.
- */
-void
-set_application_name_with_string(char *string)
-{
-       process_application_name = string;
-}
-
-/*
- * Set application name with suffix
- */
-void
-set_application_name_with_suffix(ProcessType ptype, int suffix)
-{
-       char    *appname_buf;
-
-       if (ptype < 0 || ptype >= PT_LAST_PTYPE)
-       {
-               ereport(ERROR,
-                               (errmsg("failed to set application name. process type: %d", ptype)));
-       }
-
-       appname_buf = MemoryContextAlloc(TopMemoryContext, POOLCONFIG_MAXNAMELEN);
-       snprintf(appname_buf, POOLCONFIG_MAXNAMELEN, "%s%d", application_names[ptype], suffix);
-       process_application_name = appname_buf;
-
-       return;
-}
-
-/*
- * Get current application name
- */
-char *
-get_application_name(void)
-{
-       return process_application_name;
-}
index 45a36750ac74b7b4694606ed63c00c46f6f2ffdc..8f9276a0c80c6e56776b21468f80be8b8e2662f9 100644 (file)
@@ -5,7 +5,7 @@
  * pgpool: a language independent connection pool server for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2003-2010     PgPool Global Development Group
+ * Copyright (c) 2003-2020     PgPool Global Development Group
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
  *
  * Global variables. Should be eventually removed.
  */
+#include <unistd.h> /*For getpid*/
 #include "pool.h"
+#include "utils/elog.h"
+
 
 pid_t          mypid;                          /* pgpool parent process id */
 pid_t          myProcPid;              /* process pid */
 ProcessType processType;
 ProcessState processState;
+
+/*
+ * Application name
+ */
+static char    *process_application_name = "main";
+
+/*
+ * Fixed application names. ordered by ProcessType.
+ */
+char   *application_names[] = {"main",
+                                                               "child",
+                                                               "sr_check_worker",
+                                                               "heart_beat_sender",
+                                                               "heart_beat_receiver",
+                                                               "watchdog",
+                                                               "life_check",
+                                                               "follow_child",
+                                                               "watchdog_utility",
+                                                               "pcp_main",
+                                                               "pcp_child",
+                                                               "health_check"
+};
+
+char *
+get_application_name_for_procees(ProcessType ptype)
+{
+       if (ptype < 0 || ptype >= PT_LAST_PTYPE)
+       {
+               ereport(ERROR,
+                               (errmsg("failed to set application name. process type: %d", ptype)));
+       }
+       return application_names[ptype];
+}
+
+/*
+ * Set application name by ProcessType
+ */
+void
+set_application_name(ProcessType ptype)
+{
+       process_application_name = get_application_name_for_procees(ptype);
+}
+
+/*
+ * Set application name with arbitrary string. The storage for the string must
+ * be persistent at least in the session.
+ */
+void
+set_application_name_with_string(char *string)
+{
+       process_application_name = string;
+}
+
+/*
+ * Set application name with suffix
+ */
+void
+set_application_name_with_suffix(ProcessType ptype, int suffix)
+{
+       static char     appname_buf[POOLCONFIG_MAXNAMELEN +1];
+       snprintf(appname_buf, POOLCONFIG_MAXNAMELEN, "%s%d", get_application_name_for_procees(ptype), suffix);
+       set_application_name_with_string(appname_buf);
+}
+
+/*
+ * Get current application name
+ */
+char *
+get_application_name(void)
+{
+       return process_application_name;
+}
+
+void SetProcessGlobalVaraibles(ProcessType pType)
+{
+       processType = pType;
+       myProcPid = getpid();
+       set_application_name(pType);
+}
index d60acc00bc07ddc7c1d54a717795158f2b1cb1bd..49042d39908c77ea2addd2728ad1bf2a927e97ae 100644 (file)
@@ -108,9 +108,6 @@ pcp_main(int unix_fd, int inet_fd)
        sigjmp_buf      local_sigjmp_buf;
        struct timeval uptime;
 
-       /* set application name */
-       set_application_name(PT_PCP);
-
        /* Identify myself via ps */
        init_ps_display("", "", "", "");
 
@@ -270,17 +267,12 @@ start_pcp_command_processor_process(int port)
 
        if (pid == 0)                           /* child */
        {
-               /* Set the process type variable */
-               processType = PT_PCP_WORKER;
-
-               /* set application name */
-               set_application_name(processType);
+               SetProcessGlobalVaraibles(PT_PCP_WORKER);
 
                on_exit_reset();
                /* Close the listen sockets sockets */
                close(pcp_unix_fd);
                close(pcp_inet_fd);
-               myProcPid = getpid();
                /* call PCP child main */
                if (pcp_worker_children)
                        list_free(pcp_worker_children);
index 2ee2678eed24c9d45b734109924600140a223c66..a064a5962cac02499ad50176bd71eb7105cd3f31 100644 (file)
@@ -149,8 +149,6 @@ do_child(int *fds)
        int                     connections_count = 0;  /* used if child_max_connections > 0 */
        char            psbuf[NI_MAXHOST + 128];
 
-       set_application_name(PT_CHILD);
-
        ereport(DEBUG2,
                        (errmsg("I am Pgpool Child process with pid: %d", getpid())));
 
index b04fb4d9a15e350e3cd9efc7e6bc6e9508927853..643ad51b4efbb890f61f8c475ce4485adb919a5e 100644 (file)
@@ -7,14 +7,12 @@ nodist_pg_enc_SOURCES = ssl_utils.c \
                md5.c \
                base64.c \
                pool_passwd.c \
-               pool_signal.c \
                strlcpy.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
                fe_memutils.c \
-               pool_path.c \
-               pool_globals.c
+               pool_path.c
 
 DEFS = @DEFS@ \
     -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -35,8 +33,6 @@ base64.h: ../../../src/include/utils/base64.h
        rm -f $@ && ln -s $< .
 ssl_utils.h: ../../../src/include/utils/ssl_utils.h
        rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
-       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
@@ -47,8 +43,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_pg_enc_SOURCES)
index c78dbd04c2e2970b95c7dcf7e4cf7507e97001d4..44e8505a4d8fed87b5066b83b444498508fdb24e 100644 (file)
@@ -101,11 +101,10 @@ PROGRAMS = $(bin_PROGRAMS)
 am__dirstamp = $(am__leading_dot)dirstamp
 dist_pg_enc_OBJECTS = pg_enc.$(OBJEXT) ../fe_port.$(OBJEXT)
 nodist_pg_enc_OBJECTS = ssl_utils.$(OBJEXT) md5.$(OBJEXT) \
-       base64.$(OBJEXT) pool_passwd.$(OBJEXT) pool_signal.$(OBJEXT) \
-       strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
-       pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
-       fe_memutils.$(OBJEXT) pool_path.$(OBJEXT) \
-       pool_globals.$(OBJEXT)
+       base64.$(OBJEXT) pool_passwd.$(OBJEXT) strlcpy.$(OBJEXT) \
+       regex_array.$(OBJEXT) pool_config_variables.$(OBJEXT) \
+       pool_config.$(OBJEXT) fe_memutils.$(OBJEXT) \
+       pool_path.$(OBJEXT)
 pg_enc_OBJECTS = $(dist_pg_enc_OBJECTS) $(nodist_pg_enc_OBJECTS)
 pg_enc_LDADD = $(LDADD)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -319,14 +318,12 @@ nodist_pg_enc_SOURCES = ssl_utils.c \
                md5.c \
                base64.c \
                pool_passwd.c \
-               pool_signal.c \
                strlcpy.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
                fe_memutils.c \
-               pool_path.c \
-               pool_globals.c
+               pool_path.c
 
 all: all-am
 
@@ -665,8 +662,6 @@ base64.h: ../../../src/include/utils/base64.h
        rm -f $@ && ln -s $< .
 ssl_utils.h: ../../../src/include/utils/ssl_utils.h
        rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
-       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
@@ -677,8 +672,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_pg_enc_SOURCES)
index b9881ab882738263f099abd516d850f8237bb1a2..ec0d9ba26e50bb9569243aee88adb9eed1da1c1d 100644 (file)
@@ -5,13 +5,11 @@ dist_pg_md5_SOURCES = pg_md5.c \
                ../fe_port.c
 nodist_pg_md5_SOURCES = md5.c \
                pool_passwd.c \
-               pool_signal.c \
                strlcpy.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
-               fe_memutils.c \
-               pool_globals.c
+               fe_memutils.c
 
 DEFS = @DEFS@ \
     -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -22,8 +20,6 @@ md5.h: ../../../src/include/auth/md5.h
        rm -f $@ && ln -s $< .
 pool_passwd.c: ../../../src/auth/pool_passwd.c
        rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
-       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
@@ -34,8 +30,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_pg_md5_SOURCES)
index 226b45f0db07902d4e2e2276730cb576b9d3cb57..ebd150003dcc76482826597f86942cbd88141e7e 100644 (file)
@@ -101,9 +101,9 @@ PROGRAMS = $(bin_PROGRAMS)
 am__dirstamp = $(am__leading_dot)dirstamp
 dist_pg_md5_OBJECTS = pg_md5.$(OBJEXT) ../fe_port.$(OBJEXT)
 nodist_pg_md5_OBJECTS = md5.$(OBJEXT) pool_passwd.$(OBJEXT) \
-       pool_signal.$(OBJEXT) strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
+       strlcpy.$(OBJEXT) regex_array.$(OBJEXT) \
        pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
-       fe_memutils.$(OBJEXT) pool_globals.$(OBJEXT)
+       fe_memutils.$(OBJEXT)
 pg_md5_OBJECTS = $(dist_pg_md5_OBJECTS) $(nodist_pg_md5_OBJECTS)
 pg_md5_LDADD = $(LDADD)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -315,13 +315,11 @@ dist_pg_md5_SOURCES = pg_md5.c \
 
 nodist_pg_md5_SOURCES = md5.c \
                pool_passwd.c \
-               pool_signal.c \
                strlcpy.c \
                regex_array.c \
                pool_config_variables.c \
                pool_config.c \
-               fe_memutils.c \
-               pool_globals.c
+               fe_memutils.c
 
 all: all-am
 
@@ -650,8 +648,6 @@ md5.h: ../../../src/include/auth/md5.h
        rm -f $@ && ln -s $< .
 pool_passwd.c: ../../../src/auth/pool_passwd.c
        rm -f $@ && ln -s $< .
-pool_signal.c: ../../../src/utils/pool_signal.c
-       rm -f $@ && ln -s $< .
 strlcpy.c: ../../../src/utils/strlcpy.c
        rm -f $@ && ln -s $< .
 regex_array.c: ../../../src/utils/regex_array.c
@@ -662,8 +658,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_pg_md5_SOURCES)
index e3ab79b3cda5aea3228d96d4d34daf40744335be..e54df85845dea0b202abdfd52ac95725e0bdefbf 100644 (file)
@@ -21,8 +21,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
                socket_stream.c \
                regex_array.c \
                psprintf.c \
-               md5.c \
-               pool_globals.c
+               md5.c
 
 DEFS = @DEFS@ \
     -DDEFAULT_CONFIGDIR=\"$(sysconfdir)\" -DPOOL_TOOLS
@@ -67,8 +66,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_wd_cli_SOURCES) $(dist_bin_SCRIPTS)
index 6a1f66e06d096b4d1a1874eb74d6523195541e35..9106352560ca811d21ba679eb5444d655e45f11d 100644 (file)
@@ -106,7 +106,7 @@ nodist_wd_cli_OBJECTS = ssl_utils.$(OBJEXT) wd_ipc_conn.$(OBJEXT) \
        pool_config_variables.$(OBJEXT) pool_config.$(OBJEXT) \
        fe_memutils.$(OBJEXT) stringinfo.$(OBJEXT) strlcpy.$(OBJEXT) \
        socket_stream.$(OBJEXT) regex_array.$(OBJEXT) \
-       psprintf.$(OBJEXT) md5.$(OBJEXT) pool_globals.$(OBJEXT)
+       psprintf.$(OBJEXT) md5.$(OBJEXT)
 wd_cli_OBJECTS = $(dist_wd_cli_OBJECTS) $(nodist_wd_cli_OBJECTS)
 wd_cli_LDADD = $(LDADD)
 AM_V_lt = $(am__v_lt_@AM_V@)
@@ -360,8 +360,7 @@ nodist_wd_cli_SOURCES = ssl_utils.c \
                socket_stream.c \
                regex_array.c \
                psprintf.c \
-               md5.c \
-               pool_globals.c
+               md5.c
 
 all: all-am
 
@@ -760,8 +759,6 @@ pool_config.c: ../../../src/config/pool_config.c
        rm -f $@ && ln -s $< .
 fe_memutils.c: ../../../src/tools/fe_memutils.c
        rm -f $@ && ln -s $< .
-pool_globals.c: ../../../src/main/pool_globals.c
-       rm -f $@ && ln -s $< .
 
 clean-local:
        -rm -f $(nodist_wd_cli_SOURCES) $(dist_bin_SCRIPTS)
index ae433c8ed76302f67a57f70fd3ba2a8f4eb424e0..841a349d55bd0b8144d6d1bef1c740d13bbebbf5 100644 (file)
@@ -1099,10 +1099,7 @@ fork_watchdog_child(void)
        {
                on_exit_reset();
 
-               /* Set the process type variable */
-               processType = PT_WATCHDOG;
-               myProcPid = getpid();
-               set_application_name(processType);
+               SetProcessGlobalVaraibles(PT_WATCHDOG);
 
                /* call watchdog child main */
                POOL_SETMASK(&UnBlockSig);
index 7e876043288675aee20aa8686ccaeaef687e1ade..686ac0e89a02898619d78d65a6beaeb91d382af2 100644 (file)
@@ -73,9 +73,7 @@ fork_escalation_process(void)
                return pid;
        }
        on_exit_reset();
-       processType = PT_WATCHDOG_UTILITY;
-       myProcPid = getpid();
-       set_application_name(processType);
+       SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
 
        POOL_SETMASK(&UnBlockSig);
 
@@ -163,9 +161,7 @@ fork_plunging_process(void)
                return pid;
        }
        on_exit_reset();
-       myProcPid = getpid();
-       processType = PT_WATCHDOG_UTILITY;
-       set_application_name(processType);
+       SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
 
        POOL_SETMASK(&UnBlockSig);
 
index a6ed950cd1218e8c3e2ff7b1105f90fc2afe305e..88a5914d6f0e999087eb721a7843c8ba546018cd 100644 (file)
@@ -364,9 +364,7 @@ wd_hb_receiver(int fork_wait_time, WdHbIf * hb_if)
        }
 
        on_exit_reset();
-       processType = PT_HB_RECEIVER;
-       myProcPid = getpid();
-       set_application_name(processType);
+       SetProcessGlobalVaraibles(PT_HB_RECEIVER);
 
        if (fork_wait_time > 0)
        {
@@ -499,9 +497,7 @@ wd_hb_sender(int fork_wait_time, WdHbIf * hb_if)
        }
 
        on_exit_reset();
-       myProcPid = getpid();
-       processType = PT_HB_SENDER;
-       set_application_name(processType);
+       SetProcessGlobalVaraibles(PT_HB_SENDER);
 
        if (fork_wait_time > 0)
        {
index 0c68a08c829ccaf47a78fb52cd20c571734a1a71..19ef6f4cd7cac8deeb4541c62c645685a08760f9 100644 (file)
@@ -311,9 +311,7 @@ exec_if_cmd(char *path, char *command)
        if (pid == 0)
        {
                on_exit_reset();
-               processType = PT_WATCHDOG_UTILITY;
-               set_application_name(processType);
-               myProcPid = getpid();
+               SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
                close(STDOUT_FILENO);
                dup2(pfd[1], STDOUT_FILENO);
                close(pfd[0]);
index 211ca9c2f37146c12eb857983ad879989b36e6ed..71f4374d413662af7d87499ec0364dc416aad006 100644 (file)
@@ -356,11 +356,7 @@ fork_lifecheck_child(void)
        if (pid == 0)
        {
                on_exit_reset();
-
-               /* Set the process type variable */
-               processType = PT_LIFECHECK;
-               myProcPid = getpid();
-               set_application_name(processType);
+               SetProcessGlobalVaraibles(PT_LIFECHECK);
 
                /* call lifecheck child main */
                POOL_SETMASK(&UnBlockSig);
index 760166b9c9614122fc8d32f8bfee812eef9d5a01..1eed46130c942edbd1bad0ddc1e522a4ed36325d 100644 (file)
@@ -134,9 +134,8 @@ wd_issue_ping_command(char *hostname, int *outfd)
        {
                /* CHILD */
                on_exit_reset();
-               processType = PT_WATCHDOG_UTILITY;
-               myProcPid = getpid();
-               set_application_name(processType);
+               SetProcessGlobalVaraibles(PT_WATCHDOG_UTILITY);
+
                close(STDOUT_FILENO);
                dup2(pfd[1], STDOUT_FILENO);
                close(pfd[0]);