1
votes

I'd like to list PIDs of user-processes opening my TTY driver, to be able to kill them under some conditions.

How can I get the PID of client user-processes, from my kernel module ?

2

2 Answers

0
votes

When user process calls some syscall to your driver, you are in the user thread context. Just read current pid and save it.

0
votes

When user process calls some syscall to your driver, it's doing so in the context of the process that issued the system call. You should thus be able to use the global current task structure, i.e.

pid_t mypid;
mypid = current->pid.