Sha256: 5e7dc4428bd0f81a9387b7c66b93422a046010c62332a25b83d6ede70911e3ab
Contents?: true
Size: 1.52 KB
Versions: 7
Compression:
Stored size: 1.52 KB
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 windows? @_windows = !(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM).nil? if @_windows.nil? @_windows end def mac? @_mac ||= !(/darwin/ =~ RUBY_PLATFORM).nil? if @_mac.nil? @_mac end def unix? @unix ||= !windows? if @_unix.nil? @unix end def linux? @_linux ||= unix? && !OS.mac? if @_linux.nil? @_linux end def running? process = if Contrast::Utils::OS.windows? `tasklist /fi "imagename eq contrast-service.exe"` else `ps aux | grep contrast-servic[e]` end 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
7 entries across 7 versions & 1 rubygems