Skip to content

Commit ee5dc46

Browse files
committed
Don't end up killing init if process selected to be killed terminates before the user selects a signal. Closes #3606072.
1 parent a081056 commit ee5dc46

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

ScreenManager.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
173173
for (int i = 0; i < this->panelCount; i++) {
174174
Panel* panel = (Panel*) Vector_get(this->panels, i);
175175
if (mevent.x > panel->x && mevent.x <= panel->x+panel->w &&
176-
mevent.y > panel->y && mevent.y <= panel->y+panel->h) {
176+
mevent.y > panel->y && mevent.y <= panel->y+panel->h &&
177+
(this->allowFocusChange || panelFocus == panel) ) {
177178
focus = i;
178179
panelFocus = panel;
179180
Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);

htop.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,10 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
217217
Panel* panelFocus;
218218
int ch;
219219
bool unfollow = false;
220+
Process* p = (Process*)Panel_getSelected(panel);
221+
int pid = p ? p->pid : -1;
220222
if (header->pl->following == -1) {
221-
Process* p = (Process*)Panel_getSelected(panel);
222-
header->pl->following = p ? p->pid : -1;
223+
header->pl->following = pid;
223224
unfollow = true;
224225
}
225226
ScreenManager_run(scr, &panelFocus, &ch);
@@ -231,7 +232,11 @@ static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, const cha
231232
Panel_resize(panel, COLS, LINES-y-1);
232233
FunctionBar_draw(prevBar, NULL);
233234
if (panelFocus == list && ch == 13) {
234-
return Panel_getSelected(list);
235+
Process* selected = (Process*)Panel_getSelected(panel);
236+
if (selected->pid == pid)
237+
return Panel_getSelected(list);
238+
else
239+
beep();
235240
}
236241
return NULL;
237242
}

0 commit comments

Comments
 (0)