bin/windows_ionice in windows_ionice-0.1.0 vs bin/windows_ionice in windows_ionice-0.1.1
- old
+ new
@@ -5,11 +5,15 @@
require 'frubygems' if $0 == __FILE__ && RUBY_VERSION < '1.9'
require 'sane'
require 'ruby-wmi'
require 'benchmark'
-# take a snapshot of the processes' status
+
+if (ARGV.include?('-h') || ARGV.include?("--help"))
puts '--reset-to-normal-after-awhile'
+ exit
+end
+
# take a snapshot of the processes' status
# could be more efficient by selecting just what we wanted, I suppose
def fill into_this
all = WMI::Win32_PerfRawData_PerfProc_Process.find(:all).each{|proc|
into_this[proc.IDProcess] = {:processor => proc.PercentProcessorTime.to_i, :data => proc.IODataBytesPerSec.to_i}
}
@@ -70,10 +74,12 @@
violated << pid
proc = WMI::Win32_Process.find(:first, :conditions => {:ProcessId => pid.to_i})
if proc.Priority > 4 # appears that 7 or 8 here mean normal prio...
proc.SetPriority IDLE_PRIO # set it to low priority
puts "violated!", pid, value, reading, "was greater than", max
- Thread.new { sleep 5; proc.setPriority NORMAL_PRIO; puts "set it back to normal", pid }
+ if ARGV.include? "--reset-to-normal-after-awhile"
+ Thread.new { sleep 5; proc.setPriority NORMAL_PRIO; puts "set it back to normal", pid }
+ end
end
end
}
end
}