Class: Minibidi::BrowserProcess
- Inherits:
-
Object
- Object
- Minibidi::BrowserProcess
- Defined in:
- lib/minibidi/browser_process.rb
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #dispose ⇒ Object
-
#initialize(*command) ⇒ BrowserProcess
constructor
A new instance of BrowserProcess.
- #kill ⇒ Object
Constructor Details
#initialize(*command) ⇒ BrowserProcess
Returns a new instance of BrowserProcess.
3 4 5 6 7 8 9 |
# File 'lib/minibidi/browser_process.rb', line 3 def initialize(*command) stdin, @stdout, @stderr, @thread = Open3.popen3(*command, { pgroup: true }) stdin.close @pid = @thread.pid rescue Errno::ENOENT => err raise LaunchError.new("Failed to launch browser process: #{err}") end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
22 23 24 |
# File 'lib/minibidi/browser_process.rb', line 22 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
22 23 24 |
# File 'lib/minibidi/browser_process.rb', line 22 def stdout @stdout end |
Instance Method Details
#dispose ⇒ Object
17 18 19 20 |
# File 'lib/minibidi/browser_process.rb', line 17 def dispose [@stdout, @stderr].each { |io| io.close unless io.closed? } @thread.terminate end |
#kill ⇒ Object
11 12 13 14 15 |
# File 'lib/minibidi/browser_process.rb', line 11 def kill Process.kill(:KILL, @pid) rescue Errno::ESRCH # already killed end |