'Can provide an open file description/socket ID directly to a subprocess

I'd like for Python to open a socket, but to provide that socket to a subprocess to read. For boring reasons, I'd prefer it if Python never had to read from the socket after opening the connection.

For example --- is it possible to do something like this:

socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.connect((HOST, PORT))
      # Just guessing here
    os.openSubProcess("myprocess", stdin=s.kernalSocketID)
    ...

I only care about Unix-land here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source