python 中的recvmsg 相当于什么?
我正在实现一个 python 脚本来以编程方式安装熔丝。我通过使用socketpair 和recvmsg api,用C 语言编写了等效的程序。但在 python 中,recvmsg 没有实现,所以我陷入了困境。你们谁能告诉我一个相当于这个的Python吗?任何帮助将不胜感激。
让我告诉我为什么需要recvmsg,我需要将fuse挂载的fd从子进程发送到父进程。
I am implementing a python script to do fuse mount programatically. I have written an equivalent in C, by making use of socketpair and recvmsg api's. But in python recvmsg is not implemented, so I am stuck. Can anyone of you tell me a python equivalent of this? Any help would be appreciated.
Let me tell why do I need recvmsg, I require to send the fd of the fuse mount from the child to the parent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以考虑使用 pyx 或 Python 的 C 模块来实现 C 中所需的功能,然后您可以从 Python 脚本中操作和/或使用它。这将允许您发送文件描述符并让 Python 脚本对其进行操作。
您可以做的其他事情是编写一个小的 C 包装器,它处理 recvmsg,直到它获取该 fd 并打开它后,它才会执行 fork。当您 fork 时,所有打开的文件描述符都将保持打开状态,然后执行,甚至只是普通的旧执行,这意味着您不必担心 Python 接收它。
What you could look at is using pyx or a C module for Python that implements the required functionality in C and then you can manipulate and or use it from your Python script. This would allow you to send over the file descriptor and have the Python script act upon it.
Other things you can do is write a small C wrapper, that handles the recvmsg and not until it gets that fd and has opened it does it do a fork. All file descriptors that are open will stay open when you fork, and then exec or even just plain old exec meaning you don't have to worry about Python receiving it.
作为 Python3 的一部分 socket.recvmsg 现已推出在
socket
模块中,根据文档,它应该允许你做你想做的事(尽管很晚了!):As part of Python3 socket.recvmsg is now available in the
socket
module which, according to the docs, should allow you to do what you want (albeit rather late!):