Get _complete_ process name from pid

I am in the kernel module and I want to have the full process name from the given pid. exactly: I need a line that is held in / proc / PID / cmdline.

The problem is that task_struct->comm[]it is only 15 bytes long and does not process if the program changes it argv[]manually or through setproctitle (3) ...

Any ideas? :)

+3
source share
2 answers

You can always see how the kernel does it. You will see the function:

proc_pid_cmdline(struct task_struct *task, char * buffer)

It's quite simple, but if you have one task_structfor the process you are interested in, you use access_process_vm()to cut the bits you need with mm->arg_start.

+4
source

/proc/<pid>/cmdline ?

+2

Source: https://habr.com/ru/post/1718377/


All Articles