def do_processes_require_restart()

in src/core/src/package_managers/YumPackageManager.py [0:0]


    def do_processes_require_restart(self):
        """Signals whether processes require a restart due to updates"""
        self.composite_logger.log_verbose("[YPM] Checking if process requires reboot")
        # Checking using yum-utils
        code, out = self.env_layer.run_command_output(self.yum_utils_prerequisite, False, False)  # idempotent, doesn't install if already present
        self.composite_logger.log_verbose("[YPM] Idempotent yum-utils existence check. [Code={0}][Out={1}]".format(str(code), out))

        # Checking for restart for distros with -r flag such as RHEL 7+
        code, out = self.env_layer.run_command_output(self.needs_restarting_with_flag, False, False)
        self.composite_logger.log_verbose("[YPM] > Code: " + str(code) + ", Output: \n|\t" + "\n|\t".join(out.splitlines()))
        if out.find("Reboot is required") < 0:
            self.composite_logger.log_debug("[YPM] > Reboot not detected to be required (L1).")
        else:
            self.composite_logger.log_debug("[YPM] > Reboot is detected to be required (L1).")
            return True

        # Checking for restart for distro without -r flag such as RHEL 6 and CentOS 6
        if str(self.env_layer.platform.linux_distribution()[1]).split('.')[0] == '6':
            code, out = self.env_layer.run_command_output(self.needs_restarting, False, False)
            self.composite_logger.log_verbose("[YPM] > Code: " + str(code) + ", Output: \n|\t" + "\n|\t".join(out.splitlines()))
            if len(out.strip()) == 0 and code == 0:
                self.composite_logger.log_debug("[YPM] > Reboot not detected to be required (L2).")
            else:
                self.composite_logger.log_debug("[YPM] > Reboot is detected to be required (L2).")
                return True

        # Double-checking using yum ps (where available)
        code, out = self.env_layer.run_command_output(self.yum_ps_prerequisite, False, False)  # idempotent, doesn't install if already present
        if out.find("Unable to find a match: yum-plugin-security") < 0:
            self.composite_logger.log_debug("[YPM][Info] yum-plugin-ps is not present. This is okay on RHEL8+. [Code={0}][Out={1}]".format(str(code), out))
        else:
            self.composite_logger.log_debug("[YPM] Idempotent yum-plugin-ps existence check. [Code={0}][Out={1}]".format(str(code), out))

        output = self.invoke_package_manager(self.yum_ps)
        lines = output.strip().split('\n')

        process_list_flag = False
        process_count = 0
        process_list_verbose = ""

        for line in lines:
            if not process_list_flag:  # keep going until the process list starts
                if line.find("pid") < 0 and line.find("proc") < 0 and line.find("uptime") < 0:
                    self.composite_logger.log_verbose("[YPM] > Inapplicable line: " + str(line))
                    continue
                else:
                    self.composite_logger.log_verbose("[YPM] > Process list started: " + str(line))
                    process_list_flag = True
                    continue

            process_details = re.split(r'\s+', line.strip())
            if len(process_details) < 7:
                self.composite_logger.log_verbose("[YPM] > Inapplicable line: " + str(line))
                continue
            else:
                # The first string should be process ID and hence it should be integer.
                # If first string is not process ID then the line is not for a process detail.
                try:
                    int(process_details[0])
                except Exception:
                    self.composite_logger.log_verbose("[YPM] > Inapplicable line: " + str(line))
                    continue

                self.composite_logger.log_verbose("[YPM] > Applicable line: " + str(line))
                process_count += 1
                process_list_verbose += process_details[1] + " (" + process_details[0] + "), "  # process name and id

        self.composite_logger.log_debug("[YPM] Processes requiring restart (" + str(process_count) + "): [" + process_list_verbose + "<eol>]")
        return process_count != 0  # True if there were any