� !A?h����dZddlZejdkr ed���ddlZddlZddlZddlZddlZddl Z ddl Z dZ dZ ej Z ejZej��Zdde d �d �ZGd �d ��ZGd �dej��ZdS)z)Various Windows specific bits and pieces.�N�win32z win32 only)�pipe�Popen�PIPE� PipeHandlei F)TT)�duplex� overlapped�bufsizec �R�tjd�tj��t t �������}|r*tj}tj tj z}||}}ntj }tj }d|}}|tj z}|dr|tj z}|dr tj }nd}dx} } tj||tjd||tjtj��} tj||dtjtj|tj��} tj| d���} | �d��| | fS#| �tj| ��| �tj| ���xYw)zELike os.pipe() but with overlapped support and using handles not fds.z\\.\pipe\python-pipe-{:d}-{:d}-)�prefixr�NT�r )�tempfile�mktemp�format�os�getpid�next� _mmap_counter�_winapi�PIPE_ACCESS_DUPLEX� GENERIC_READ� GENERIC_WRITE�PIPE_ACCESS_INBOUND�FILE_FLAG_FIRST_PIPE_INSTANCE�FILE_FLAG_OVERLAPPED�CreateNamedPipe� PIPE_WAIT�NMPWAIT_WAIT_FOREVER�NULL� CreateFile� OPEN_EXISTING�ConnectNamedPipe�GetOverlappedResult� CloseHandle) rr r �address�openmode�access�obsize�ibsize�flags_and_attribs�h1�h2�ovs �B/opt/alt/python-internal/lib64/python3.11/asyncio/windows_utils.pyrr s����o�1�8�8� �I�K�K��m�,�,�.�.�/�/�/�G��$��-���%��(=�=�� �'�����.���&���G��� ��5�5�H��!�}�1��G�0�0���!�}��#�8������N�B��� � $� �X�w�0� �v�v�w�;�W�\�K�K��� � �V�Q�� �g�.C� �w�|�-�-��� %�b�T� :� :� :�� ���t�$�$�$��2�v� ��� �>� � �� #� #� #� �>� � �� #� #� #� ���s �BE7�7/F&c�p�eZdZdZd�Zd�Zed���Zd�Ze j d�d�Z e j fd�Zd �Zd �Zd S) rz�Wrapper for an overlapped pipe handle which is vaguely file-object like. The IOCP event loop can use these instead of socket objects. c��||_dS�N��_handle��self�handles r/�__init__zPipeHandle.__init__Vs ���� � � �c�P�|j� d|j��}nd}d|jj�d|�d�S)Nzhandle=�closed�<� �>)r4� __class__�__name__r5s r/�__repr__zPipeHandle.__repr__Ys>�� �<� #�/�t�|�/�/�F�F��F�6�4�>�*�6�6�V�6�6�6�6r9c��|jSr2r3�r6s r/r7zPipeHandle.handle`s ���|�r9c�<�|j�td���|jS)NzI/O operation on closed pipe)r4� ValueErrorrCs r/�filenozPipeHandle.filenods!�� �<� ��;�<�<� <��|�r9)r%c�F�|j�||j��d|_dSdSr2r3)r6r%s r/�closezPipeHandle.closeis/�� �<� #� �K�� � %� %� %��D�L�L�L� $� #r9c�l�|j�,|d|��t|���|���dSdS)Nz unclosed )�source)r4�ResourceWarningrH)r6�_warns r/�__del__zPipeHandle.__del__nsC�� �<� #� �E�&�d�&�&��� E� E� E� E� �J�J�L�L�L�L�L� $� #r9c��|Sr2�rCs r/� __enter__zPipeHandle.__enter__ss��� r9c�.�|���dSr2)rH)r6�t�v�tbs r/�__exit__zPipeHandle.__exit__vs�� � � � � � � � r9N)r@� __module__� __qualname__�__doc__r8rA�propertyr7rFrr%rH�warnings�warnrMrPrUrOr9r/rrQs������������7�7�7�����X����� $+�#6� � � � � � %�M����� �������r9rc�$��eZdZdZd�fd� Z�xZS)rz�Replacement for subprocess.Popen using overlapped pipe handles. The stdin, stdout, stderr are None or instances of PipeHandle. Nc �&��dx}x}}dx} x} } |tkr4tdd���\} } tj| tj��}n|}|tkr)td���\} } tj| d��}n|}|tkr)td���\} }tj|d��}n|t kr|}n|} t��j|f|||d�|��| �t| ��|_ | �t| ��|_ | �t| ��|_ n$#| | | fD]}|�tj|����xYw|tkrt j|��|tkrt j|��|tkrt j|��dSdS#|tkrt j|��|tkrt j|��|tkrt j|��wwxYw)N)FTT)r r)TFrr)�stdin�stdout�stderr)rr�msvcrt�open_osfhandler�O_RDONLY�STDOUT�superr8rr^r_r`rr%rH)r6�argsr^r_r`�kwds� stdin_rfd� stdout_wfd� stderr_wfd�stdin_wh� stdout_rh� stderr_rh�stdin_rh� stdout_wh� stderr_wh�hr?s �r/r8zPopen.__init__�sG���/3�2� �2�J��+/�/��/�9�y� �D�=�=�!%��t�!L�!L�!L� �H�h��-�h�� �D�D�I�I��I� �T�>�>�#'�=�#A�#A�#A� �I�y��.�y�!�<�<�J�J��J� �T�>�>�#'�=�#A�#A�#A� �I�y��.�y�!�<�<�J�J� �v� � �#�J�J��J� %� �E�G�G� �T� 8��:�$.� 8� 8�26� 8� 8� 8��#�'��1�1�� ��$�(��3�3�� ��$�(��3�3�� ��� �� �9�5� +� +���=��'��*�*�*�� ������}�}����#�#�#���~�~����$�$�$���~�~����$�$�$�$�$��~�� ��}�}����#�#�#���~�~����$�$�$���~�~����$�$�$�$����s � D+�(AF0�+!E � F0�0A H)NNN)r@rVrWrXr8� __classcell__)r?s@r/rr}sG���������+%�+%�+%�+%�+%�+%�+%�+%�+%�+%r9r)rX�sys�platform� ImportErrorr� itertoolsrar� subprocessrrZ�__all__�BUFSIZErrd�countrrrrrOr9r/�r{s%��/�/� � � � ��<�7��� �+�l� #� #�#��������� � � � � � � � ������������� 0�� ����� � ��� ��!�!� � �\�7�+�+�+�+�+�b&�&�&�&�&�&�&�&�X0%�0%�0%�0%�0%�J� �0%�0%�0%�0%�0%r9