在现代 Linux 上,是否有更简单的方法在不相关的进程之间共享文件描述符(即 ver>=3.0.0)?
Linux 是否提供了一种更好的方法将 fd 从一个进程发送到另一个进程以进行共享,而不是使用 sendmsg()
系统调用来发送它(类型设置为 SCM_RIGHTS
的消息) >) 通过 UNIX 域套接字?我想最好的可能性是以某种方式能够命名一个 fd,然后在一个不相关的进程中打开它(按名称),但我对其他替代方案持开放态度。
我问这个问题的原因是能够使用 *fd() 函数(例如,eventfd()
、timerfd()
、signalfd()
等...)在没有父子关系的进程之间,使得共享文件描述符变得更加困难。
Does Linux provide a better way to send an fd from one process to another, for sharing, than using a sendmsg()
syscall to send it (a message with type set to SCM_RIGHTS
) over a UNIX Domain socket? I guess the best possibility would be to somehow be able to name an fd and then open it (by name) in an unrelated process, but I am open to other alternatives.
The reason I am asking this question is to be able to use the *fd() functions (e.g., eventfd()
, timerfd()
, signalfd()
, etc...) between processes with no parent-child relationship, making it much more difficult to share file descriptors.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个库可以为您执行此操作,位于 https://www.normalesup.org/ ~george/comp/libancillary/ 通过复制到其树中而在许多项目中使用,但主要 git 主机不再存在。
There is a library to do this for you at https://www.normalesup.org/~george/comp/libancillary/ which is used in a number of projects by copying into their tree, but the primary git host is no longer alive.