Class ProcessManagement

    • Field Detail

      • log

        protected static final org.apache.log4j.Logger log
    • Constructor Detail

      • ProcessManagement

        protected ProcessManagement()
    • Method Detail

      • getPsDetectionCommand

        public abstract String getPsDetectionCommand()
      • isWindows

        public static boolean isWindows()
      • isMac

        public static boolean isMac()
      • isUnix

        public static boolean isUnix()
      • generateStackTrace

        public abstract void generateStackTrace​(int pid,
                                                String command)
      • getGentleKillCmd

        public abstract String getGentleKillCmd​(String pid)
      • getRudeKillCmd

        public abstract String getRudeKillCmd​(String pid)
      • getStackTraceAndKillRelatedProcesses

        public void getStackTraceAndKillRelatedProcesses​(int pid)
                                                  throws Exception
        Entry point method for this class in the HBK plugin

        This method will get a stack trace and kill the subprocesses (and orphans) related to the process with 'pid' id. In Bamboo build that will effectively stop a build and collect valuable information.

        Parameters:
        pid - Usually the bamboo's agent pid.
        Throws:
        Exception
      • buildLog

        public String buildLog​(String message,
                               boolean isError)
      • executeCommand

        public void executeCommand​(String command,
                                   boolean readOutput)
        Need to capture the output of some process, e.g. jstack.
        Parameters:
        command - to be executed
        readOutput -
      • getRelatedProcesses

        public Set<Map<String,​String>> getRelatedProcesses​(int pid,
                                                                 Map<Integer,​Map<String,​String>> pids)
        get all descendants from 'pid' We are also interested in orphans processes related to our pid so we also need to filter children of 1 (orphan process) with the same process group id groups id's are the only reliable way of getting related processes http://www.steve.org.uk/Reference/Unix/faq_2.html#SEC26
        Parameters:
        pid -
        pids -
        Returns: