我在内核中搜索“ getpid ”函数,但是我找不到实际的函数。
它应该是这样的:
asmlinkage long sys_getpid(void)
{
return current-> tgetid;
}
我所能找到的只是系统调用表,而不是这个系统调用的实际实现。
内核版本为: 3.0.20
提前致谢。
答案 0 :(得分:5)
实际定义位于kernel/timer.c
:
/**
* sys_getpid - return the thread group id of the current process
*
* Note, despite the name, this returns the tgid not the pid. The tgid and
* the pid are identical unless CLONE_THREAD was specified on clone() in
* which case the tgid is the same in all threads of the same group.
*
* This is SMP safe as current->tgid does not change.
*/
SYSCALL_DEFINE0(getpid)
{
return task_tgid_vnr(current);
}
task_tgid_vnr
是include/linux/sched.h
中的静态内联。