Sha256: 21332fc3d82651872f66d80cd6c54827db6c9b4a72ef32b8458dc852627a5f20

Contents?: true

Size: 917 Bytes

Versions: 1

Compression:

Stored size: 917 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
   if pids.length > 1
     puts "found more than one -- waiting for all #{pids.inspect}"
   end
   pids.each{|pid| 
     puts "waiting for #{pid}"
     WaitPid.wait_nonchild_pid pid 
   }
  end
  
  def self.wait_pid pid
    WaitPid.wait_nonchild_pid pid
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
after-0.3.1 lib/after.rb