从一个程序传递文件描述符到另一个使用Unix套接字在同一主机上 [英] Passing file descriptor from one program to another on the same host using UNIX sockets

查看:180
本文介绍了从一个程序传递文件描述符到另一个使用Unix套接字在同一主机上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个prgrams可以说PROG1和PROG2。我打开与PROG1的文件,并做一些操作
在上面。现在无需关闭文件中PROG1我发送的文件描述符PROG2使用unix
插座,然后做它的一些操作。

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.

虽然我得到同样的描述我在PROG1通过,但这样做对FD在收到一个PROG2 FSTAT()
抛出一个错误,说坏的文件描述符。我已经打开了文件中PROG1与corerct权限
即读写所有,还是我得到一个错误。

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

还有信息的Linux的人7 UNIX 使用 SCM_RIGHTS 和Unix套接字的其他功能。

There's also information in Linux's man 7 unix on using SCM_RIGHTS and other features of Unix sockets.

修复了损坏的链接:http://web.archive.org/web/20131016032959/http://www.lst.de/~okir/blackhats/node121.html

这篇关于从一个程序传递文件描述符到另一个使用Unix套接字在同一主机上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆