Method: Process.setpriority
- Defined in:
- lib/puppet/util/windows/monkey_patches/process.rb
.setpriority(kind, int, int_priority) ⇒ Object
Sets the priority class for the specified process id int.
The kind parameter is ignored but present for API compatibility. You can only retrieve process information, not process group or user information, so it is effectively always Process::PRIO_PROCESS.
Possible int_priority values are:
-
Process::NORMAL_PRIORITY_CLASS
-
Process::IDLE_PRIORITY_CLASS
-
Process::HIGH_PRIORITY_CLASS
-
Process::REALTIME_PRIORITY_CLASS
-
Process::BELOW_NORMAL_PRIORITY_CLASS
-
Process::ABOVE_NORMAL_PRIORITY_CLASS
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/puppet/util/windows/monkey_patches/process.rb', line 181 def setpriority(kind, int, int_priority) raise TypeError unless kind.is_a?(Integer) raise TypeError unless int.is_a?(Integer) raise TypeError unless int_priority.is_a?(Integer) int = Process.pid if int == 0 handle = OpenProcess(PROCESS_SET_INFORMATION, 0, int) if handle == 0 raise SystemCallError, FFI.errno, "OpenProcess" end begin result = SetPriorityClass(handle, int_priority) raise SystemCallError, FFI.errno, "SetPriorityClass" unless result ensure FFI::WIN32.CloseHandle(handle) end 0 end |