On Linux, how to get the pid of a system call process

I am trying to understand how a system call works in the Linux kernel. One of my questions is: how can I get the pid of the process making the system call?

eg. I look at a call read()(read synchronization), which, it seems to me, is defined in fs / read_write.c as

ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos)
+3
source share
1 answer

In the context of the system call (which is the context of the calling process), you can check the global variable currentwhich is of type struct task_struct, it contains a field pidfrom which you can get the pid.

current->pid, pid , .

, , .

+7

All Articles