Auto-follow process when selecting which signal to use when killing a process.

This avoids killing the wrong process.
This commit is contained in:
Hisham Muhammad 2012-03-30 01:20:32 +00:00
parent bca656c79e
commit 05a78c8111
2 changed files with 11 additions and 1 deletions

View File

@ -236,6 +236,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable) {
this->detailedCPUTime = false; this->detailedCPUTime = false;
this->countCPUsFromZero = false; this->countCPUsFromZero = false;
this->treeStr = NULL; this->treeStr = NULL;
this->following = -1;
return this; return this;
} }
@ -915,7 +916,7 @@ void ProcessList_rebuildPanel(ProcessList* this, bool flags, int following, bool
} }
int currPos = Panel_getSelectedIndex(this->panel); int currPos = Panel_getSelectedIndex(this->panel);
pid_t currPid = following ? following : 0; pid_t currPid = following != -1 ? following : 0;
int currScrollV = this->panel->scrollV; int currScrollV = this->panel->scrollV;
Panel_prune(this->panel); Panel_prune(this->panel);

9
htop.c
View File

@ -207,7 +207,16 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
ScreenManager_add(scr, panel, NULL, -1); ScreenManager_add(scr, panel, NULL, -1);
Panel* panelFocus; Panel* panelFocus;
int ch; int ch;
bool unfollow = false;
if (header->pl->following == -1) {
Process* p = (Process*)Panel_getSelected(panel);
header->pl->following = p ? p->pid : -1;
unfollow = true;
}
ScreenManager_run(scr, &panelFocus, &ch); ScreenManager_run(scr, &panelFocus, &ch);
if (unfollow) {
header->pl->following = -1;
}
ScreenManager_delete(scr); ScreenManager_delete(scr);
Panel_move(panel, 0, y); Panel_move(panel, 0, y);
Panel_resize(panel, COLS, LINES-y-1); Panel_resize(panel, COLS, LINES-y-1);