Sending FDs over UNIX domain sockets

Fabiano Sidler <[email protected]>
Newsgroups gmane.comp.python.general
Message-ID <[email protected]>
Hi folks!

I'm trying to pass some file descriptors over a UNIX domain socket.
But either I'm doing something wrong, or there is a bug in Python.
Here's my code:


=== testclient start ===
#!/usr/bin/env python3

from socket import socket, AF_UNIX, SOCK_STREAM, send_fds
import sys

path = '/tmp/test'

s = socket(AF_UNIX, SOCK_STREAM)
s.connect(path)
send_fds(s, [bytes()], [
     sys.stdin.fileno(),
     sys.stdout.fileno(),
     sys.stderr.fileno()
], 3, None)
=== testclient end ===


=== testserver start ===
#!/usr/bin/env python3

from socket import socket, AF_UNIX, SOCK_STREAM, recv_fds
from os.path import exists
from os import remove

path = '/tmp/test'

s = socket(AF_UNIX, SOCK_STREAM)
if exists(path):
     remove(path)
s.bind(path)
s.listen(-1)
c,_ = s.accept()
fds = recv_fds(c, 1024, 3)
print(fds)
=== testserver end ===


What's the issue?

Best wishes,
Fabiano

-- 
https://mail.python.org/mailman3//lists/python-list.python.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.