Send an array of fds over an AF_UNIX socket.
(sock, fds)
| 140 | import array |
| 141 | |
| 142 | def sendfds(sock, fds): |
| 143 | '''Send an array of fds over an AF_UNIX socket.''' |
| 144 | fds = array.array('i', fds) |
| 145 | msg = bytes([len(fds) % 256]) |
| 146 | sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, fds)]) |
| 147 | if sock.recv(1) != b'A': |
| 148 | raise RuntimeError('did not receive acknowledgement of fd') |
| 149 | |
| 150 | def recvfds(sock, size): |
| 151 | '''Receive an array of fds over an AF_UNIX socket.''' |
no test coverage detected
searching dependent graphs…