Module: Win32Open4
- Defined in:
- lib/procreate/win32/open4.rb
Overview
An implementation of Open4 for windows, based largely on a post by Simon Kröger to comp.lang.ruby - “Problem with popen on windows” (groups.google.com/group/comp.lang.ruby/browse_thread/thread/a40bac71df1f4a4c).
Provides an api that loosely matches Ara Howard’s Open4 (at least for Open4.background so far).
Defined Under Namespace
Modules: Kernel32 Classes: ProcessHandler
Class Method Summary collapse
-
.background(cmdline, params = {}) ⇒ Object
Launches a process asynchronously, and returns a thread that can be used to retrieve exit status, or wait for completion.
Class Method Details
.background(cmdline, params = {}) ⇒ Object
Launches a process asynchronously, and returns a thread that can be used to retrieve exit status, or wait for completion. All calls used are non-blocking such that it works safely with ruby’s green threads.
Note that while broadly compatible there are a number of differences from original Open4.background - eg parameters like :status are ignored (in fact it works like :status => true in that it won’t throw exceptions).
280 281 282 283 284 285 286 287 288 289 290 |
# File 'lib/procreate/win32/open4.rb', line 280 def self.background cmdline, params={} ph = ProcessHandler.new cmdline, params pid = ph.instance_variable_get :@processId thread = Thread.new { ph.run } sc = class << thread; self; end sc.module_eval do define_method(:pid) { pid } define_method(:exitstatus) { value } end thread end |