I have two prgrams lets say prog1 and prog2. I am opening a file with prog1 and doing some operations on it. Now without closing the file in prog1 i am sending its file descriptor to prog2 using unix sockets which then does some operations in it.
Though i get the same descriptor i passed in prog1 but doing a fstat() on the fd recieved in prog2 throws an error saying Bad file descriptor. I have opened the file in prog1 with corerct permissions that is read and write for all, still i get an error.
Why is it happening so. If my way of passing a file descriptor is wrong then please suggest a correct one.
I believe this site has what you're looking for:
http://www.lst.de/~okir/blackhats/node121.html
There's also information in Linux's man 7 unix
on using SCM_RIGHTS
and other features of Unix sockets.
Fix for broken link: http://web.archive.org/web/20131016032959/http://www.lst.de/~okir/blackhats/node121.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With