在现代 Linux 上,是否有更简单的方法在不相关的进程之间共享文件描述符(即 ver>=3.0.0)?

发布于 2024-12-14 06:05:53 字数 342 浏览 2 评论 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅唱ヾ落雨殇 2024-12-21 06:05:54

有一个库可以为您执行此操作,位于 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文