%PDF- %PDF-
Direktori : /lib/python3/dist-packages/pyudev/_os/__pycache__/ |
Current File : //lib/python3/dist-packages/pyudev/_os/__pycache__/pipe.cpython-312.pyc |
� 9*�bL � � � d Z ddlZddlZddlmZ ddlmZmZmZ ddl m Z eedd� Zd� Z d � Zd � Z e� Zd� Zd� Z G d � d� Zy)a# pyudev._os.pipe =============== Fallback implementations for pipe. 1. pipe2 from python os module 2. pipe2 from libc 3. pipe from python os module The Pipe class wraps the chosen implementation. .. moduleauthor:: Sebastian Wiesner <lunaryorn@gmail.com> � N)�partial)�ERROR_CHECKERS�FD_PAIR� SIGNATURES)�load_ctypes_library� O_CLOEXECi c �N � t � }| j ||� |d |d fS )z�A ``pipe2`` implementation using ``pipe2`` from ctypes. ``libc`` is a :class:`ctypes.CDLL` object for libc. ``flags`` is an integer providing the flags to ``pipe2``. Return a pair of file descriptors ``(r, w)``. r � )r �pipe2)�libc�flags�fdss �1/usr/lib/python3/dist-packages/pyudev/_os/pipe.py� _pipe2_ctypesr - s+ � � �)�C��J�J�s�E���q�6�3�q�6�>�� c �� � t j � }| t j z dk7 r!|D ] }t |t j � � | t z dk7 r|D ] }t |t � � |S )z�A ``pipe2`` implementation using :func:`os.pipe`. ``flags`` is an integer providing the flags to ``pipe2``. .. warning:: This implementation is not atomic! Return a pair of file descriptors ``(r, w)``. r )�os�pipe� O_NONBLOCK�set_fd_status_flagr �set_fd_flag)r r �file_descriptors r �_pipe2_by_piper ; sh � � �'�'�)�C��r�}�}���!�"� ?�O���� � �>� ?��y��A��"� 4�O����3� 4��Jr c �� � t t d� rt j S t dt t � } t | d� rt t | � S t S # t $ r t cY S w xY w)zf Find the appropriate implementation for ``pipe2``. Return a function implementing ``pipe2``.r r ) �hasattrr r r r r r r r �ImportError)r s r �_get_pipe2_implementationr Q sa � � �r�7���x�x���"�6�:�~�F��,3�D�'�,B�G�M�4�(� �HV� �� � ����s �0A �A �A+�*A+c � � t j | t j d� }t j | t j ||z � y)zwSet a flag on a file descriptor. ``fd`` is the file descriptor or file object, ``flag`` the flag as integer. r N)�fcntl�F_GETFD�F_SETFD��fd�flagr s r r r d �2 � � �K�K��E�M�M�1�-�E� �K�K��E�M�M�5�4�<�0r c � � t j | t j d� }t j | t j ||z � y)z~Set a status flag on a file descriptor. ``fd`` is the file descriptor or file object, ``flag`` the flag as integer. r N)r �F_GETFL�F_SETFLr"