86 lines
3.0 KiB
Diff
86 lines
3.0 KiB
Diff
From fb2a412e086be7169e42b7169292c35f9e3063ce Mon Sep 17 00:00:00 2001
|
|
From: cielavenir <cielartisan@gmail.com>
|
|
Date: Fri, 9 Jul 2021 14:27:30 +0900
|
|
Subject: [PATCH 1/2] killall: call load_proc_cmdline if the length is
|
|
OLD_COMM_LEN-1 as well
|
|
|
|
---
|
|
src/killall.c | 9 +++++----
|
|
1 file changed, 5 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/killall.c b/src/killall.c
|
|
index 9fab8f5..645aaa1 100644
|
|
--- a/src/killall.c
|
|
+++ b/src/killall.c
|
|
@@ -426,7 +426,7 @@ load_process_name_and_age(char *comm, double *process_age_sec,
|
|
}
|
|
|
|
static int
|
|
-load_proc_cmdline(const pid_t pid, const char *comm, char **command, int *got_long)
|
|
+load_proc_cmdline(const pid_t pid, const char *comm, const int check_comm_length, char **command, int *got_long)
|
|
{
|
|
FILE *file;
|
|
char *path, *p, *command_buf;
|
|
@@ -482,7 +482,7 @@ load_proc_cmdline(const pid_t pid, const char *comm, char **command, int *got_lo
|
|
}
|
|
p = strrchr(command_buf,'/');
|
|
p = p ? p+1 : command_buf;
|
|
- if (strncmp(p, comm, COMM_LEN-1) == 0) {
|
|
+ if (strncmp(p, comm, check_comm_length) == 0) {
|
|
okay = 1;
|
|
if (!(*command = strdup(p))) {
|
|
free(command_buf);
|
|
@@ -664,8 +664,9 @@ kill_all(int signal, int name_count, char **namelist, struct passwd *pwent,
|
|
free(command);
|
|
command = NULL;
|
|
}
|
|
- if (length == COMM_LEN - 1)
|
|
- if (load_proc_cmdline(pid_table[i], comm, &command, &got_long) < 0)
|
|
+
|
|
+ if (length == COMM_LEN - 1 || length == OLD_COMM_LEN - 1)
|
|
+ if (load_proc_cmdline(pid_table[i], comm, length, &command, &got_long) < 0)
|
|
continue;
|
|
|
|
/* match by process name */
|
|
--
|
|
GitLab
|
|
|
|
|
|
From 43af55f4c4e5972a1354c6cafeca85ecd38dc122 Mon Sep 17 00:00:00 2001
|
|
From: cielavenir <cielartisan@gmail.com>
|
|
Date: Fri, 9 Jul 2021 14:30:37 +0900
|
|
Subject: [PATCH 2/2] killall: match_process_name comparision with got_long
|
|
should be full-length
|
|
|
|
---
|
|
src/killall.c | 6 ++----
|
|
1 file changed, 2 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/src/killall.c b/src/killall.c
|
|
index 645aaa1..7bfb9a9 100644
|
|
--- a/src/killall.c
|
|
+++ b/src/killall.c
|
|
@@ -564,8 +564,7 @@ static int match_process_name(
|
|
{
|
|
if (got_long)
|
|
{
|
|
- return (0 == strncmp2 (match_name, proc_cmdline, OLD_COMM_LEN - 1,
|
|
- ignore_case));
|
|
+ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
|
|
} else {
|
|
return (0 == strncmp2 (match_name, proc_comm, OLD_COMM_LEN - 1,
|
|
ignore_case));
|
|
@@ -576,8 +575,7 @@ static int match_process_name(
|
|
{
|
|
if (got_long)
|
|
{
|
|
- return (0 == strncmp2 (match_name, proc_cmdline, COMM_LEN - 1,
|
|
- ignore_case));
|
|
+ return (0 == strcmp2 (match_name, proc_cmdline, ignore_case));
|
|
} else {
|
|
return (0 == strncmp2 (match_name, proc_comm, COMM_LEN - 1,
|
|
ignore_case));
|
|
--
|
|
GitLab
|
|
|