0

I am interested in kernel development, and I am trying to find a way to terminate and kill a process. The only thing that I know is pid and task descriptor value of that process.

In other words, how can I kill a process by using its pid or pointer to its task_struct in kernel ?

  • When I write my question, I explicitly add the phare in kernel. I have to kill the process in kernel modules. – Goktug Oct 24 '18 at 21:02
  • 1
    If your question gets closed you can try posting on Stack Overflow which handles mainly programming questions. – WinEunuuchs2Unix Oct 25 '18 at 2:04
  • 1
    I think this question is more suited to StackOverflow because it's specifically about computer programming. – code_dredd Oct 25 '18 at 5:24
1
  1. The code you could reference is oom killer at mm/oom_kill.c

    https://github.com/torvalds/linux/blob/master/mm/oom_kill.c

    This is the mechanism when system is out of memory, kernel will choose some process to kill.

  2. Android LMK is relatively simpler. It is using send_sig. https://android.googlesource.com/kernel/arm64/+/android-9.0.0_r0.32/drivers/staging/android/lowmemorykiller.c

  3. Or you can use int kill_pid(struct pid *pid, int sig, int priv) function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.