Re: Getting the PID
Re: Getting the PID
- Subject: Re: Getting the PID
- From: Brian Bergstrand <email@hidden>
- Date: Wed, 10 Dec 2003 18:18:53 -0600
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
No. The number you get back from socket() or open() is no good without
a corresponding PID. In the kernel, each process contains an array of
pointers to kernel file structures. The number you get back from
socket() or open() (the "file descriptor") is just the index into the
process's array of file pointers. So without know what process you are
dealing with, there is no way to correlate a descriptor (index) number
to anything. And even knowing what process it is, you still can't
guarantee anything, since the descriptor could be invalid or pointing
to another file by the time you get around to querying for it.
HTH.
On Dec 10, 2003, at 5:45 PM, Matt Jaffa wrote:
>
Ok,
>
>
I am trying to get the PID of something.
>
All I basically have to work with is
>
a socket file descriptor.
>
>
say when you do this int so = socket(....,....., ...., ... etc.);
>
>
you get back the socket file descriptor, now how can i take that
>
number and see which process created it?
>
>
Thanks,
>
Matt
>
Brian Bergstrand <
http://www.bergstrand.org/brian/>
PGP Key: <
http://www.bergstrand.org/brian/misc/public_key.txt>
AIM: triryche206
It is impossible to enjoy idling thoroughly unless one has plenty of
work to do. - Jerome K. Jerome
-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3
iQA/AwUBP9ep5HnR2Fu2x7aiEQIdvACfUyEuG9NNvMylECAymDqoRkSC2BUAoKIU
0yeTdcSo4Tu4Sz6Vi+V+KAnk
=fRYz
-----END PGP SIGNATURE-----
_______________________________________________
darwin-kernel mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/darwin-kernel
Do not post admin requests to the list. They will be ignored.