o
    ¯b÷  ã                   @   sš   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ de	dee	e
f fdd„Zed	krKee	ejd
 ƒƒ\ZZe  ede d ¡ e  e¡ dS dS )é    N)Úunpack)ÚTuple)ÚrecvmsgÚsocketfdÚreturnc           	      C   s@   t  | t jt j¡}t|ƒ\}}}|\\}}}td|ƒ\}||fS )az  
    Receive a file descriptor from a L{sendmsg} message on the given C{AF_UNIX}
    socket.

    @param socketfd: An C{AF_UNIX} socket, attached to another process waiting
        to send sockets via the ancillary data mechanism in L{send1msg}.

    @param fd: C{int}

    @return: a 2-tuple of (new file descriptor, description).
    @rtype: 2-tuple of (C{int}, C{bytes})
    Úi)ÚsocketÚfromfdÚAF_UNIXÚSOCK_STREAMr   r   )	r   Ú	ourSocketÚdataÚ	ancillaryÚflagsÚ	cmsgLevelÚcmsgTypeÚpackedFDÚ
unpackedFD© r   ú>/usr/lib/python3/dist-packages/twisted/python/test/pullpipe.pyÚrecvfd   s
   r   Ú__main__é   s   Test fixture data: s   .
)Úosr   ÚsysÚstructr   Útypingr   Útwisted.python.sendmsgr   ÚintÚbytesr   Ú__name__ÚargvÚfdÚdescriptionÚwriteÚcloser   r   r   r   Ú<module>   s   ý