Sha256: 36196ea28aa3076eef868d408687ab3e3ed4fc0a9de825c86e465c7dfe8bd751

Contents?: true

Size: 557 Bytes

Versions: 1

Compression:

Stored size: 557 Bytes

Contents

# frozen_string_literal: true

module Nonnative
  class System
    def initialize(process)
      @process = process
      @started = false
    end

    def start
      unless started
        @pid = spawn(process.command, %i[out err] => [process.file, 'a'])
        @started = true
      end

      pid
    end

    def stop
      raise Nonnative::Error, "Can't stop a process that has not started" unless started

      ::Process.kill('SIGINT', pid)
      @started = false

      pid
    end

    private

    attr_reader :process, :pid, :started
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nonnative-1.3.0 lib/nonnative/system.rb