SYSCALL_DEFINE0(getpid)
return task_tgid_vnr(current);
=>static inline pid_t task_tgid_vnr(struct task_struct *tsk)
return pid_vnr(task_tgid(tsk));
=>static inline struct pid *task_tgid(struct task_struct *task)
return task->group_leader->pids[PIDTYPE_PID].pid;
轻松理解 struct pid
https://blog.youkuaiyun.com/lovelycheng/article/details/78359945
慢慢欣赏linux 进程的领头线程 领头进程 领头会话
最新推荐文章于 2023-03-22 17:48:38 发布
本文详细解析了Linux系统中getpid系统调用的实现原理,从源代码层面介绍了如何通过task_struct结构体获取当前进程的ID。通过跟踪内核函数调用,揭示了task_tgid_vnr和task_tgid等关键函数的作用,帮助读者深入理解进程ID的获取机制。
1631

被折叠的 条评论
为什么被折叠?



