Re: Getting pid from a sock?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2006-12-26 at 15:22 +0100, Phasip wrote:
> Hello, i have tried to get pid from a struct sock without luck.
> I tried
> 
> //It's named sock_i_pid coz i stole most of it from sock_i_uid.
> int sock_i_pid(struct sock *sk)
>  {
>          int pid;
>          read_lock(&sk->sk_callback_lock);
>          pid = sk->sk_socket ? sk->sk_socket->file->f_owner.pid : 0;
>          read_unlock(&sk->sk_callback_lock);
>          return pid;
>  }
> 
> But this always returns 0, even if i change it to set pid to 1 if
> sk_socket doesn't exist.

How are you testing this function?  What code are you running from
user-space that causes the function to be called?

Avishay


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux