Class: ObjectiveCommand::Runners::Fork

Inherits:
Exec show all
Defined in:
lib/objective_command/runners/fork.rb

Direct Known Subclasses

Popen, System

Instance Attribute Summary

Attributes inherited from Runner

#command_data_factory

Instance Method Summary collapse

Methods inherited from Exec

#exec

Methods inherited from Runner

#apply_options, #initialize, #initialize_copy, #make_debug, #make_verbose, #raise_on_failures, #run

Methods included from Mockable

#make_mock

Methods included from Hooker

#hook_method

Methods included from Hookable

#disable_hook, #hook_trigger, #hooker_subscribe, #subscribe_hook

Constructor Details

This class inherits a constructor from ObjectiveCommand::Runners::Runner

Instance Method Details

#abort(data) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/objective_command/runners/fork.rb', line 25

def abort ( data )
  if data.pid
    begin
      hook_trigger :kill, data
      hook_trigger :waitpid, data
    rescue Errno::ESRCH
      hook_trigger :already_killed, data
    end
  end
end

#before_exec(command, data) ⇒ Object



56
57
58
# File 'lib/objective_command/runners/fork.rb', line 56

def before_exec ( command, data )
  TempPath.clean
end

#exception_raised_during_exec(anException) ⇒ Object



37
38
39
40
41
# File 'lib/objective_command/runners/fork.rb', line 37

def exception_raised_during_exec ( anException )
  STDERR.reopen(File.new(1))
  STDERR.puts anException
  exit! 127
end

#failure(command, data) ⇒ Object



49
50
51
52
53
# File 'lib/objective_command/runners/fork.rb', line 49

def failure command, data
  if data.status and data.status.signaled?
    data.status.instance_eval { @exitstatus = 134 }
  end
end

#fork(data, &block) ⇒ Object

Methods



17
18
19
20
21
22
# File 'lib/objective_command/runners/fork.rb', line 17

def fork data, &block
  data.pid = Kernel.fork do
    TempPath.fork_init true
    block.call
  end
end

#kill(data) ⇒ Object



44
45
46
# File 'lib/objective_command/runners/fork.rb', line 44

def kill ( data )
  data.kill
end