Guru Prasad
Guru Prasad

Reputation: 4223

When and where is a process named in Linux

I've been trying to follow the flow of process creation on Linux. So far, I've put in a few debug printk's to understand pid allocation on the Linux kernel. However, now I wish to map PIDs to binaries as they are being created (or executed).

I know that the way Linux creates processes is by forking off init and then doing an exec..or doing an exec directly from init..

I'm trying to trace when and where the field comm on the new task_struct is being filled.. The comm field stores the binary being executed. So far, no matter where I try to print the comm field (execept during the context_switch function), all processes always display their name as khelper

I've tried extensively debugging the do_execve function, but that just doesn't seem to contain code related to changing of the comm field..

Could someone point out where and when the comm field is assigned

Upvotes: 4

Views: 876

Answers (2)

Jesus Ramos
Jesus Ramos

Reputation: 23268

Correction: The function is setup_new_exec in fs/exec.c it calls set_task_comm which actually sets this field.

Upvotes: 3

Guru Prasad
Guru Prasad

Reputation: 4223

I've found that setup_new_exec in fs/exec.c fills in the comm field in the struct task_struct for most user processes. However, this does not seem to happen for a lot of processes that are started within the kernel itself..

Upvotes: 0

Related Questions