I'm trying to print the comm
field of the current
task_struct
to print the name of a process. Then, using current->parent
, I want to do the same thing for all the current process's ancestors.
Here's what I've got so far:
while (there is still an ancestor of current to print) {
...
printk("Name: %s", current_task->comm);
...
}
And here's the result (pid
shown to the left of the process names):
As you can see, the first and last processes aren't printing correctly. I understand why the first one is being truncated -- current->comm
is an array of 16 char
s, and so there is simply no room for the final "r" in process_ancestor (the name of my program). However, I don't understand why swapper
has the null terminator appended to it. Is there any chance that this is actually the name of the process? Or is something else going wrong?