Class: Nasty::BackgroundJob
Instance Method Summary collapse
-
#initialize(process) ⇒ BackgroundJob
constructor
A new instance of BackgroundJob.
- #run ⇒ Object
- #stop(signal = "TERM") ⇒ Object
Constructor Details
#initialize(process) ⇒ BackgroundJob
Returns a new instance of BackgroundJob.
3 4 5 |
# File 'lib/nasty/background_job.rb', line 3 def initialize(process) @process = process end |
Instance Method Details
#run ⇒ Object
7 8 9 10 11 |
# File 'lib/nasty/background_job.rb', line 7 def run @pid = fork do exec @process end end |
#stop(signal = "TERM") ⇒ Object
13 14 15 16 17 18 |
# File 'lib/nasty/background_job.rb', line 13 def stop(signal = "TERM") if @pid Process.kill(signal, @pid) Process.wait(@pid) end end |