Class: Charai::BrowserProcess
- Inherits:
-
Object
- Object
- Charai::BrowserProcess
- Defined in:
- lib/charai/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.
5 6 7 8 9 10 11 |
# File 'lib/charai/browser_process.rb', line 5 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.
24 25 26 |
# File 'lib/charai/browser_process.rb', line 24 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
24 25 26 |
# File 'lib/charai/browser_process.rb', line 24 def stdout @stdout end |
Instance Method Details
#dispose ⇒ Object
19 20 21 22 |
# File 'lib/charai/browser_process.rb', line 19 def dispose [@stdout, @stderr].each { |io| io.close unless io.closed? } @thread.terminate end |
#kill ⇒ Object
13 14 15 16 17 |
# File 'lib/charai/browser_process.rb', line 13 def kill Process.kill(:KILL, @pid) rescue Errno::ESRCH # already killed end |