Search code examples
clinuxkernel-module

How can I flag a process from a kernel module?


I have a kernel module(in c), which is working and would like to:

  1. accept input from a user for a process number
  2. mark that process as SIGNAL_UNKILLABLE as in the linux source code

#define SIGNAL_UNKILLABLE 0x00000040 /* for init: ignore fatal signals */

I created a kernel module in c and searched online, but no working results.


Solution

  • How can I flag a process from a kernel module?

    Looking at https://elixir.bootlin.com/linux/v6.0.19/A/ident/SIGNAL_UNKILLABLE, should be super normally.

    struct task_struct *t = find_task_by_vpid(thepid);
    t->signal->flags |= SIGNAL_UNKILLABLE;