From e9b64be5230f0b498d8d78a8e67158a843594f83 Mon Sep 17 00:00:00 2001 From: axtloss Date: Wed, 3 Jul 2024 18:43:35 +0200 Subject: kill-processes: add project --- kill-processes/meow.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 kill-processes/meow.c (limited to 'kill-processes/meow.c') diff --git a/kill-processes/meow.c b/kill-processes/meow.c new file mode 100644 index 0000000..1283e92 --- /dev/null +++ b/kill-processes/meow.c @@ -0,0 +1,63 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int pid = 1; + +DECLARE_WAIT_QUEUE_HEAD(wq); + +struct task_struct *task1; + +void procs_info_print(void) +{ + struct task_struct* task_list; + size_t process_counter = 0; + for_each_process(task_list) { + if (strcmp (task_list->comm, "qalculate-gtk") == 0) { + pr_info("%s [%d]\n", task_list->comm, task_list->pid); + pr_info ("killing qalculate %d\n", task_list->pid); + struct siginfo info; + struct task_struct *task; + memset (&info, 0, sizeof (struct siginfo)); + info.si_signo = SIGTERM; + info.si_code = SI_QUEUE; + info.si_int = 1234; + rcu_read_lock (); + task = pid_task (find_pid_ns (task_list->pid, &init_pid_ns), PIDTYPE_PID); + if (!task) { + printk ("pid lost\n"); + rcu_read_unlock (); + } + } + } +} + +int run(void *data) +{ + while (true) { + procs_info_print(); + usleep_range(1000000, 1000001); + } + return 0; +} + +int init_module(void) +{ + printk(KERN_INFO "arf arf ^w^\n"); + task1 = kthread_create (&run, &pid, "teehee"); + wake_up_process (task1); + return 0; +} + +void cleanup_module(void) +{ + return; +} + +MODULE_LICENSE("GPL"); -- cgit v1.2.3