Parent

ChildProcess::AbstractProcess

Constants

POLL_INTERVAL

Attributes

detach[RW]

Set this to true if you do not care about when or if the process quits.

duplex[RW]

Set this to true if you want to write to the process' stdin (process.io.stdin)

exit_code[R]

Public Class Methods

new(args) click to toggle source

Create a new process with the given args.

@api private @see ChildProcess.build

# File lib/childprocess/abstract_process.rb, line 24
def initialize(args)
  @args      = args
  @started   = false
  @exit_code = nil
  @io        = nil
  @detach    = false
  @duplex    = false
end

Public Instance Methods

alive?() click to toggle source

Is this process running?

@return [Boolean]

# File lib/childprocess/abstract_process.rb, line 84
def alive?
  started? && !exited?
end
crashed?() click to toggle source

Returns true if the process has exited and the exit code was not 0.

@return [Boolean]

# File lib/childprocess/abstract_process.rb, line 94
def crashed?
  exited? && @exit_code != 0
end
exited?() click to toggle source

Did the process exit?

@return [Boolean]

# File lib/childprocess/abstract_process.rb, line 74
def exited?
  raise SubclassResponsibility, "exited?"
end
io() click to toggle source

Returns a ChildProcess::AbstractIO subclass to configure the child's IO streams.

# File lib/childprocess/abstract_process.rb, line 37
def io
  raise SubclassResponsibility, "io"
end
pid() click to toggle source
# File lib/childprocess/abstract_process.rb, line 41
def pid
  raise SubclassResponsibility, "pid"
end
poll_for_exit(timeout) click to toggle source

Wait for the process to exit, raising a ChildProcess::TimeoutError if the timeout expires.

# File lib/childprocess/abstract_process.rb, line 103
def poll_for_exit(timeout)
  log "polling #{timeout} seconds for exit"

  end_time = Time.now + timeout
  until (ok = exited?) || Time.now > end_time
    sleep POLL_INTERVAL
  end

  unless ok
    raise TimeoutError, "process still alive after #{timeout} seconds"
  end
end
start() click to toggle source

Launch the child process

@return [AbstractProcess] self

# File lib/childprocess/abstract_process.rb, line 51
def start
  launch_process
  @started = true

  self
end
stop(timeout = 3) click to toggle source

Forcibly terminate the process, using increasingly harsher methods if possible.

@param [Fixnum] timeout (3) Seconds to wait before trying the next method.

# File lib/childprocess/abstract_process.rb, line 64
def stop(timeout = 3)
  raise SubclassResponsibility, "stop"
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.