mirror of https://github.com/xzeldon/htop.git
Experimental feature: beep on permission failures.
Update dates.
This commit is contained in:
parent
a839c3f2ca
commit
cf7fdcd1d6
|
@ -42,7 +42,7 @@ typedef enum ProcessField_ {
|
||||||
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
|
STIME, CUTIME, CSTIME, PRIORITY, NICE, ITREALVALUE, STARTTIME, VSIZE, RSS, RLIM, STARTCODE, ENDCODE,
|
||||||
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
|
STARTSTACK, KSTKESP, KSTKEIP, SIGNAL, BLOCKED, SSIGIGNORE, SIGCATCH, WCHAN, NSWAP, CNSWAP, EXIT_SIGNAL,
|
||||||
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
|
PROCESSOR, M_SIZE, M_RESIDENT, M_SHARE, M_TRS, M_DRS, M_LRS, M_DT, ST_UID, PERCENT_CPU, PERCENT_MEM,
|
||||||
USER, TIME, NLWP, TGID
|
USER, TIME, NLWP, TGID,
|
||||||
#ifdef HAVE_OPENVZ
|
#ifdef HAVE_OPENVZ
|
||||||
VEID, VPID,
|
VEID, VPID,
|
||||||
#endif
|
#endif
|
||||||
|
@ -187,12 +187,13 @@ void Process_toggleTag(Process* this) {
|
||||||
this->tag = this->tag == true ? false : true;
|
this->tag = this->tag == true ? false : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_setPriority(Process* this, int priority) {
|
bool Process_setPriority(Process* this, int priority) {
|
||||||
int old_prio = getpriority(PRIO_PROCESS, this->pid);
|
int old_prio = getpriority(PRIO_PROCESS, this->pid);
|
||||||
int err = setpriority(PRIO_PROCESS, this->pid, priority);
|
int err = setpriority(PRIO_PROCESS, this->pid, priority);
|
||||||
if (err == 0 && old_prio != getpriority(PRIO_PROCESS, this->pid)) {
|
if (err == 0 && old_prio != getpriority(PRIO_PROCESS, this->pid)) {
|
||||||
this->nice = priority;
|
this->nice = priority;
|
||||||
}
|
}
|
||||||
|
return (err == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Process_getAffinity(Process* this) {
|
unsigned long Process_getAffinity(Process* this) {
|
||||||
|
@ -201,8 +202,8 @@ unsigned long Process_getAffinity(Process* this) {
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_setAffinity(Process* this, unsigned long mask) {
|
bool Process_setAffinity(Process* this, unsigned long mask) {
|
||||||
sched_setaffinity(this->pid, sizeof(unsigned long), (cpu_set_t*) &mask);
|
return (sched_setaffinity(this->pid, sizeof(unsigned long), (cpu_set_t*) &mask) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_sendSignal(Process* this, int signal) {
|
void Process_sendSignal(Process* this, int signal) {
|
||||||
|
|
|
@ -141,11 +141,11 @@ void Process_display(Object* cast, RichString* out);
|
||||||
|
|
||||||
void Process_toggleTag(Process* this);
|
void Process_toggleTag(Process* this);
|
||||||
|
|
||||||
void Process_setPriority(Process* this, int priority);
|
bool Process_setPriority(Process* this, int priority);
|
||||||
|
|
||||||
unsigned long Process_getAffinity(Process* this);
|
unsigned long Process_getAffinity(Process* this);
|
||||||
|
|
||||||
void Process_setAffinity(Process* this, unsigned long mask);
|
bool Process_setAffinity(Process* this, unsigned long mask);
|
||||||
|
|
||||||
void Process_sendSignal(Process* this, int signal);
|
void Process_sendSignal(Process* this, int signal);
|
||||||
|
|
||||||
|
|
28
htop.c
28
htop.c
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
htop - htop.c
|
htop - htop.c
|
||||||
(C) 2004-2006 Hisham H. Muhammad
|
(C) 2004-2007 Hisham H. Muhammad
|
||||||
Released under the GNU GPL, see the COPYING file
|
Released under the GNU GPL, see the COPYING file
|
||||||
in the source distribution for its full text.
|
in the source distribution for its full text.
|
||||||
*/
|
*/
|
||||||
|
@ -36,14 +36,14 @@ in the source distribution for its full text.
|
||||||
|
|
||||||
void printVersionFlag() {
|
void printVersionFlag() {
|
||||||
clear();
|
clear();
|
||||||
printf("htop " VERSION " - (C) 2004-2006 Hisham Muhammad.\n");
|
printf("htop " VERSION " - (C) 2004-2007 Hisham Muhammad.\n");
|
||||||
printf("Released under the GNU GPL.\n\n");
|
printf("Released under the GNU GPL.\n\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void printHelpFlag() {
|
void printHelpFlag() {
|
||||||
clear();
|
clear();
|
||||||
printf("htop " VERSION " - (C) 2004-2006 Hisham Muhammad.\n");
|
printf("htop " VERSION " - (C) 2004-2007 Hisham Muhammad.\n");
|
||||||
printf("Released under the GNU GPL.\n\n");
|
printf("Released under the GNU GPL.\n\n");
|
||||||
printf("-d DELAY Delay between updates, in tenths of seconds\n\n");
|
printf("-d DELAY Delay between updates, in tenths of seconds\n\n");
|
||||||
printf("-u USERNAME Show only processes of a given user\n\n");
|
printf("-u USERNAME Show only processes of a given user\n\n");
|
||||||
|
@ -56,7 +56,7 @@ void printHelpFlag() {
|
||||||
void showHelp(ProcessList* pl) {
|
void showHelp(ProcessList* pl) {
|
||||||
clear();
|
clear();
|
||||||
attrset(CRT_colors[HELP_BOLD]);
|
attrset(CRT_colors[HELP_BOLD]);
|
||||||
mvaddstr(0, 0, "htop " VERSION " - (C) 2004-2006 Hisham Muhammad.");
|
mvaddstr(0, 0, "htop " VERSION " - (C) 2004-2007 Hisham Muhammad.");
|
||||||
mvaddstr(1, 0, "Released under the GNU GPL. See 'man' page for more info.");
|
mvaddstr(1, 0, "Released under the GNU GPL. See 'man' page for more info.");
|
||||||
|
|
||||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||||
|
@ -151,18 +151,21 @@ static void Setup_run(Settings* settings, int headerHeight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool changePriority(Panel* panel, int delta) {
|
static bool changePriority(Panel* panel, int delta) {
|
||||||
|
bool ok = true;
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
for (int i = 0; i < Panel_getSize(panel); i++) {
|
for (int i = 0; i < Panel_getSize(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(panel, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_setPriority(p, p->nice + delta);
|
ok = Process_setPriority(p, p->nice + delta) && ok;
|
||||||
anyTagged = true;
|
anyTagged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!anyTagged) {
|
if (!anyTagged) {
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_setPriority(p, p->nice + delta);
|
ok = Process_setPriority(p, p->nice + delta) && ok;
|
||||||
}
|
}
|
||||||
|
if (!ok)
|
||||||
|
beep();
|
||||||
return anyTagged;
|
return anyTagged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -608,20 +611,25 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
|
Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
|
||||||
|
|
||||||
char* fuFunctions[2] = {"Toggle ", "Done "};
|
char* fuFunctions[2] = {"Set ", "Cancel "};
|
||||||
pickFromList(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
|
void* set = pickFromList(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
|
||||||
|
if (set) {
|
||||||
unsigned long new = AffinityPanel_getAffinity(affinityPanel);
|
unsigned long new = AffinityPanel_getAffinity(affinityPanel);
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
|
bool ok = true;
|
||||||
for (int i = 0; i < Panel_getSize(panel); i++) {
|
for (int i = 0; i < Panel_getSize(panel); i++) {
|
||||||
Process* p = (Process*) Panel_get(panel, i);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_setAffinity(p, new);
|
ok = Process_setAffinity(p, new) && ok;
|
||||||
anyTagged = true;
|
anyTagged = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!anyTagged) {
|
if (!anyTagged) {
|
||||||
Process* p = (Process*) Panel_getSelected(panel);
|
Process* p = (Process*) Panel_getSelected(panel);
|
||||||
Process_setAffinity(p, new);
|
ok = Process_setAffinity(p, new) && ok;
|
||||||
|
}
|
||||||
|
if (!ok)
|
||||||
|
beep();
|
||||||
}
|
}
|
||||||
((Object*)affinityPanel)->delete((Object*)affinityPanel);
|
((Object*)affinityPanel)->delete((Object*)affinityPanel);
|
||||||
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
|
|
Loading…
Reference in New Issue