Sha256: ed9b1fcc519f80d6afcc0442730f39ef6a670c3a16ceb842bfee53e3cba3ac62

Contents?: true

Size: 703 Bytes

Versions: 3

Compression:

Stored size: 703 Bytes

Contents

require 'ruby-wmi' # wow not even pretended linux compat. yet
require 'sane'
require 'wait_pid'

class After

  def self.find_pids(many_args)

    procs = WMI::Win32_Process.find(:all)
    pids = []
    for proc in procs # TODO respect proc.Name!
      if proc.CommandLine && proc.CommandLine.contain?(many_args)
        pid = proc.ProcessId.to_i
        next if pid == Process.pid
        pids << pid
        if $VERBOSE
         print 'adding ', proc.ProcessId, ' ', proc.Name, ' ', proc.CommandLine, "\n"
        end
      end
    end
    pids
  end

  def self.find_and_wait_for(args)
   pids = find_pids args
   pids.each{|pid| WaitPid.wait_nonchild_pid pid }
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
after-0.2.1 lib/after.rb
after-0.1.0 lib/after.rb
after-0.0.4 lib/after.rb