Sha256: ff4eda5f72b7cb16eafaf26d30decc7b1b009324470284798266258b7fe923ed
Contents?: true
Size: 1.53 KB
Versions: 17
Compression:
Stored size: 1.53 KB
Contents
module RunLoop # A class for interacting with the lldb command-line tool class LLDB # Returns a list of lldb pids. # @return [Array<Integer>] An array of integer pids. def self.lldb_pids ps_output = `#{LLDB_FIND_PIDS_CMD}`.strip lines = ps_output.lines("\n").map { |line| line.strip } lldb_processes = lines.select { |line| self.is_lldb_process?(line) } lldb_processes.map do |ps_description| tokens = ps_description.strip.split(' ').map { |token| token.strip } pid = tokens.fetch(0, nil) if pid.nil? nil else pid.to_i end end.compact.sort end # @!visibility private # Is the process described an lldb process? # # @param [String] ps_details Details about a process as returned by `ps` # @return [Boolean] True if the details describe an lldb process. def self.is_lldb_process?(ps_details) return false if ps_details.nil? ps_details[/Contents\/Developer\/usr\/bin\/lldb/, 0] != nil end # Attempts to gracefully kill all running lldb processes. def self.kill_lldb_processes self.lldb_pids.each do |pid| unless self.kill_with_signal(pid, 'TERM') self.kill_with_signal(pid, 'KILL') end end end private # @!visibility private LLDB_FIND_PIDS_CMD = 'ps x -o pid,command | grep -v grep | grep lldb' # @!visibility private def self.kill_with_signal(pid, signal) RunLoop::ProcessTerminator.new(pid, signal, 'lldb').kill_process end end end
Version data entries
17 entries across 17 versions & 1 rubygems