Send an array of fds over an AF_UNIX socket.
(sock, fds)
| 143 | ACKNOWLEDGE = sys.platform == 'darwin' |
| 144 | |
| 145 | def sendfds(sock, fds): |
| 146 | '''Send an array of fds over an AF_UNIX socket.''' |
| 147 | fds = array.array('i', fds) |
| 148 | msg = bytes([len(fds) % 256]) |
| 149 | sock.sendmsg([msg], [(socket.SOL_SOCKET, socket.SCM_RIGHTS, fds)]) |
| 150 | if ACKNOWLEDGE and sock.recv(1) != b'A': |
| 151 | raise RuntimeError('did not receive acknowledgement of fd') |
| 152 | |
| 153 | def recvfds(sock, size): |
| 154 | '''Receive an array of fds over an AF_UNIX socket.''' |
no test coverage detected