Class: Steam::Process
- Inherits:
-
Object
- Object
- Steam::Process
- Defined in:
- lib/steam/process.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #fork(options) ⇒ Object
-
#initialize(path = '/tmp') ⇒ Process
constructor
A new instance of Process.
- #kill(signal = 'TERM') ⇒ Object
- #pid? ⇒ Boolean
- #running? ⇒ Boolean
Constructor Details
#initialize(path = '/tmp') ⇒ Process
Returns a new instance of Process.
5 6 7 8 |
# File 'lib/steam/process.rb', line 5 def initialize(path = '/tmp') @path = path recall_pid end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/steam/process.rb', line 3 def path @path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
3 4 5 |
# File 'lib/steam/process.rb', line 3 def pid @pid end |
Instance Method Details
#fork(options) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/steam/process.rb', line 20 def fork() @pid = Kernel.fork { yield } write_pid # Process.detach(pid) ? at_exit { kill } unless [:keep_alive] end |
#kill(signal = 'TERM') ⇒ Object
27 28 29 30 31 |
# File 'lib/steam/process.rb', line 27 def kill(signal = 'TERM') ::Process.kill(Signal.list[signal], pid) delete_pid true end |
#pid? ⇒ Boolean
10 11 12 |
# File 'lib/steam/process.rb', line 10 def pid? !!pid end |
#running? ⇒ Boolean
14 15 16 17 18 |
# File 'lib/steam/process.rb', line 14 def running? pid? && !!::Process.getpgid(pid) rescue Errno::ESRCH false end |