import subprocess
import os
import pwd
+import struct
def _shuffle_fd3():
os.dup2(1,3)
(s2, dummy) = s.accept()
(msg, ancil, flags, sender) = s2.recvmsg(1, ancil_len)
- got_fds = [ ]
+ got_fds = None
+ unpack_fmt = '%di' % len(fds)
for clvl, ctype, cdata in ancil:
if clvl == socket.SOL_SOCKET and ctype == socket.SCM_RIGHTS:
- got_fds += cdata # need to trim any surplus, and unpack
+ assert(got_fds is None)
+ got_fds = struct.unpack_from(unpack_fmt, cdata)
finally:
if s is not None: s.close()
try: os.remove(our_sockname)
except FileNotFoundError: pass
+
+ return list(got_fds)