Search code examples
pythonsocketsfuse

what is recvmsg equivalent in python?


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.


Solution

  • 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.