task_struct结构体中comm成员

struct task_struct结构体中有一个comm成员,
struct task_struct {
...
 char comm[TASK_COMM_LEN]; /* executable name excluding path
...
}
在《professional linux kernel architecture》中是这样注释的:
char comm[TASK_COMM_LEN]; /* executable name excluding path
 - access with [gs]et_task_comm (which lock
 it with task_lock())
 - initialized normally by flush_old_exec */
kernel代码的打印信息中常可看到使用该成员表示相关进程信息,例如
 printk(KERN_INFO "note: %s[%d] exited\n",
  current->comm, task_pid_nr(current));

使用函数set_task_comm设置该成员的值,使用函数get_task_comm获取该成员的值。
char *get_task_comm(char *buf, struct task_struct *tsk)
void set_task_comm(struct task_struct *tsk, char *buf)


有一个调用set_task_comm的路径是这样的:
load_elf_binary
 setup_new_exec(bprm)
  set_task_comm(current, tcomm);

load_elf_binary函数用来处理elf文件格式
static struct linux_binfmt elf_format = {
  .module  = THIS_MODULE,
  .load_binary = load_elf_binary,
  .load_shlib = load_elf_library,
  .core_dump = elf_core_dump,
  .min_coredump = ELF_EXEC_PAGESIZE,
  .hasvdso = 1
};
static int __init init_elf_binfmt(void)
{
 return register_binfmt(&elf_format);
}
/* Registration of default binfmt handlers */
static inline int register_binfmt(struct linux_binfmt *fmt)
{
 return __register_binfmt(fmt, 0);
}
后面再仔细看看binfmt相关处理细节

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值