Sha256: 837bdb7e70b177ed15f0f88d08a23b13569188c3f4bdb70a0f26afcbd844e17e

Contents?: true

Size: 915 Bytes

Versions: 4

Compression:

Stored size: 915 Bytes

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module Contrast
  module Utils
    # Simple utility used to make OS calls and determine state. For that state
    # which will not change at runtime, such as the operating system, the
    # Utility memozies to avoid multiple lookups.
    module OS
      class << self
        def running?
          process = `ps aux | grep contrast-servic[e]`
          process != ''
        end

        # check if service was killed and is a zombie process
        # returns an array of zombie process PIDs as strings; empty array if there are none
        def zombie_pids
          zombie_pid_list = `ps aux | grep contrast-servic[e] | grep Z | awk '{print $2}'` # retrieve pid of service processes
          zombie_pid_list.split("\n")
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
contrast-agent-3.12.2 lib/contrast/utils/os.rb
contrast-agent-3.12.1 lib/contrast/utils/os.rb
contrast-agent-3.12.0 lib/contrast/utils/os.rb
contrast-agent-3.11.0 lib/contrast/utils/os.rb