Sha256: 791be2e4d6b98a15fbf5132e1eea33f8a4089fa0d8cc4633aa27179982be84a7

Contents?: true

Size: 600 Bytes

Versions: 4

Compression:

Stored size: 600 Bytes

Contents

module RakeUp
  module Utilities
    class ProcessCheck
      attr_reader :pid, :error

      def initialize(pid)
        @pid = pid.to_i
      end

      def run
        begin
          info = Process.getpgid(pid)
          @running = true
        rescue Errno::ESRCH => error
          @running = false
          @error = error
        end
      end

      def running?
        @running
      end

      def to_s
        if running?
          "Found process running with pid #{pid}"
        else
          "Unable to find process with pid #{pid}: #{@error}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rakeup-1.2.0 lib/rakeup/utilities/process_check.rb
rakeup-1.1.0 lib/rakeup/utilities/process_check.rb
rakeup-1.0.1 lib/rakeup/utilities/process_check.rb
rakeup-1.0.0 lib/rakeup/utilities/process_check.rb