From a8cbfdae4097e8ee0a9ac9d4a747fcd7f47d95a4 Mon Sep 17 00:00:00 2001 From: DeltachangeOG Date: Fri, 23 Jan 2026 21:29:29 -0600 Subject: [PATCH 1/4] sendSginalContext refactor with clean build --- Process.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Process.c b/Process.c index cd1c08688..f5f83ab38 100644 --- a/Process.c +++ b/Process.c @@ -19,6 +19,7 @@ in the source distribution for its full text. #include #include #include +#include #include "CRT.h" #include "Hashtable.h" @@ -901,14 +902,25 @@ bool Process_rowChangePriorityBy(Row* super, Arg delta) { return Process_setPriority(this, (int)this->nice + delta.i); } -static bool Process_sendSignal(Process* this, Arg sgn) { - return kill(Process_getPid(this), sgn.i) == 0; +static bool Process_sendSignal(Process* this, Process_sendSignalContext* ctx) { + if (kill(Process_getPid(this), ctx->sgn ) != 0) { + int e = errno; + if (e == EPERM) { + ctx->sawEperm = true; + } + if (e != ESRCH) { + ctx->lastRealErrno = e; + } + return false; + } + return true; } -bool Process_rowSendSignal(Row* super, Arg sgn) { +bool Process_rowSendSignal(Row* super, Arg arg) { Process* this = (Process*) super; assert(Object_isA((const Object*) this, (const ObjectClass*) &Process_class)); - return Process_sendSignal(this, sgn); + Process_sendSignalContext* ctx = (Process_sendSignalContext*) arg.v; + return Process_sendSignal(this, ctx); } int Process_compare(const void* v1, const void* v2) { From 720d8bc30fb39cbff06c295e8e351bef2e2ca128 Mon Sep 17 00:00:00 2001 From: DeltachangeOG Date: Fri, 23 Jan 2026 22:37:13 -0600 Subject: [PATCH 2/4] Display error context, beep no ESRCH error only --- Action.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Action.c b/Action.c index 1d3bccc51..45bdab4b1 100644 --- a/Action.c +++ b/Action.c @@ -526,11 +526,25 @@ static Htop_Reaction actionKill(State* st) { Panel_setHeader((Panel*)st->mainPanel, "Sending..."); Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st)); refresh(); - bool ok = MainPanel_foreachRow(st->mainPanel, Process_rowSendSignal, (Arg) { .i = sgn->key }, NULL); - if (!ok) { + bool ok = MainPanel_foreachRow(st->mainPanel, Process_rowSendSignal, (Arg) { .v = &ctx }, NULL); + (void) ok; + if (ctx.sawEperm) { beep(); + Panel_setHeader((Panel*)st->mainPanel, "Permission denied (try running as root)"); + Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st)); + refresh(); + napms(1500); + } + else if (ctx.lastRealErrno != 0) { + beep(); + Panel_setHeader((Panel*)st->mainPanel, strerror(ctx.lastRealErrno)); + Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st)); + refresh(); + napms(1500); + } + else { + napms(500); } - napms(500); } Panel_delete((Object*)signalsPanel); From 29448cc1c073ef36f2721575a1553af97bf2afa9 Mon Sep 17 00:00:00 2001 From: DeltachangeOG Date: Sat, 24 Jan 2026 13:04:34 -0600 Subject: [PATCH 3/4] Final changes, clean build --- Action.c | 5 +++++ Process.h | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Action.c b/Action.c index 45bdab4b1..bdf1cfd18 100644 --- a/Action.c +++ b/Action.c @@ -519,9 +519,14 @@ static Htop_Reaction actionKill(State* st) { static int preSelectedSignal = SIGNALSPANEL_INITSELECTEDSIGNAL; + Process_sendSignalContext ctx; + Panel* signalsPanel = SignalsPanel_new(preSelectedSignal); const ListItem* sgn = (ListItem*) Action_pickFromVector(st, signalsPanel, 14, true); if (sgn && sgn->key != 0) { + ctx.sgn = sgn->key; + ctx.sawEperm = false; + ctx.lastRealErrno = 0; preSelectedSignal = sgn->key; Panel_setHeader((Panel*)st->mainPanel, "Sending..."); Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st)); diff --git a/Process.h b/Process.h index 38e2711f6..3f4b83e55 100644 --- a/Process.h +++ b/Process.h @@ -309,6 +309,12 @@ const char* Process_rowGetSortKey(Row* super); bool Process_rowChangePriorityBy(Row* super, Arg delta); +typedef struct Process_sendSignalContext_ { + int sgn; + bool sawEperm; + int lastRealErrno; +} Process_sendSignalContext; + bool Process_rowSendSignal(Row* super, Arg sgn); bool Process_rowIsHighlighted(const Row* super); From ddd7e0addc5744d2d4c5199b659082aba21dc170 Mon Sep 17 00:00:00 2001 From: DeltachangeOG Date: Sat, 24 Jan 2026 18:55:39 -0600 Subject: [PATCH 4/4] change permission warning text --- Action.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Action.c b/Action.c index bdf1cfd18..702a899e6 100644 --- a/Action.c +++ b/Action.c @@ -535,7 +535,7 @@ static Htop_Reaction actionKill(State* st) { (void) ok; if (ctx.sawEperm) { beep(); - Panel_setHeader((Panel*)st->mainPanel, "Permission denied (try running as root)"); + Panel_setHeader((Panel*)st->mainPanel, "Permission denied"); Panel_draw((Panel*)st->mainPanel, false, true, true, State_hideFunctionBar(st)); refresh(); napms(1500);