26 #include <sys/resource.h> 37 const char* usage =
"Usage: sc_info priority <pid> [normal|idle]";
38 if (argc < 3 || argc > 4)
43 bool idlePriority =
false;
59 HANDLE hProcess = OpenProcess(
60 PROCESS_SET_INFORMATION | PROCESS_QUERY_INFORMATION,
false, pid);
65 SetPriorityClass(hProcess, idlePriority ? IDLE_PRIORITY_CLASS
66 : NORMAL_PRIORITY_CLASS);
68 uint priorityClass = GetPriorityClass(hProcess);
69 CloseHandle(hProcess);
71 return UI_Result(ti,
OK, priorityClass == NORMAL_PRIORITY_CLASS ? 0 : 15);
76 if (setpriority(PRIO_PROCESS, pid, idlePriority ? 15 : 0) != 0)
80 int priority = getpriority(PRIO_PROCESS, pid);
82 #endif // #ifdef WIN32
UI_res_t sc_info_priority(UI_extra_t, UI_handle_t ti, int argc, const char **argv)
const errorT ERROR_BadArg
int strGetInteger(const char *str)
UI_res_t UI_Result(UI_handle_t ti, errorT res)
UI_Result() - pass the result of an operation from c++ to UI.