我正在内核中搜索“getpid”函数,但是我找不到实际的函数。
应该是这样的:
asmlinkage long sys_getpid(void)
{
return current-> tgetid;
}
我能找到的只是系统调用表,而不是这个系统调用的实际实现。
内核版本是:3.0.20
提前致谢。
实际定义在
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
中的静态内联。