File: //opt/cloudlinux/venv/lib64/python3.11/site-packages/guppy/etc/__pycache__/xterm.cpython-311.pyc
�
    � h=	  �                   �L   � d dl Z d dlZd dlZd\  ZZZd� Zd� Zd	d�Zd	d�Z	d� Z
dS )
�    N)r   �   �   c                  �  � 	 dd l } 	 | �                    t          j        dd�  �        \  }}n&# t          $ r}t          j        |�  �        �d }~ww xY w||fS # t          $ r Y nw xY wdD ]R}dD ]M}d|z   |z   }	 t          j        |t          j        �  �        }n# t
          j        $ r Y �<w xY w|d|z   |z   fc c S �St          j        d�  �        �)Nr   i�  �pqrstuvwxyzPQRST�0123456789abcdefz/dev/ptyz/dev/ttyzout of pty devices)	�sgi�_getpty�fcntl�O_RDWR�IOError�os�error�ImportError�open)r   �tty_name�	master_fd�msg�x�y�pty_name�fds           �D/opt/cloudlinux/venv/lib/python3.11/site-packages/guppy/etc/xterm.py�master_openr      s/  � �	#��
�
�
�	 �"%�+�+�e�l�E�1�"E�"E��H�i�i��� 	 � 	 � 	 ��(�3�-�-������	 �����(�"�"�� � 
� 
� 
���
����  � ,� ,��#� 	,� 	,�A�!�A�~��)�H�
��W�X�u�|�4�4�����8� 
� 
� 
���
�����
�Q���*�+�+�+�+�+�+�
	,� 
�(�'�
(�
(�(s7   �A �$, �
A�A
�
A�
A#�"A#�7B�B)�(B)c                 �@   � t          j        | t          j        �  �        S )N)r
   r   r
   r   )r   s    r   �
slave_openr   .   s   � �
�7�8�U�\�*�*�*�    � c                 �6  � t          �   �         \  }}t          j        �   �         }|r�t          |�  �        }t          j        |t
          �  �         t          j        |t          �  �         t          j        |t          �  �         |t          k    rt          j        |�  �         t          j        |�  �         t          j
        �                    �   �          | �
 | �   �          n7t          j        �   �          d||dd �         |fz  }t          j
        |�  �         |S )Nzxterm %s -S%s%d���)r   r
   �forkr   �dup2�STDIN_FILENO�
STDOUT_FILENO�
STDERR_FILENO�close�sys�stdin�readline�setsid�system)�prog�optionsr   r   �pid�slave_fd�cmds          r   �xtermr0   2   s�   � �%�-�-��I�x�
�'�)�)�C�
� ��h�'�'�� 	���,�'�'�'�
���-�(�(�(�
���-�(�(�(��}�$�$��H�X����
�������	���������D�F�F�F��
�	�����7�H�R�S�S�M�9�"E�E��
�	�#�����Jr   c                 �   � t          j        �   �         }|r|S t          j        �   �          t          | |�  �        }|st          j        d�  �         d S d S )Nr   )r
   r    r)   r0   �_exit)r+   r,   r-   s      r   �	forkxtermr3   K   sW   � �
�'�)�)�C�
� ��
�
�	�����D�'�"�"��� 	��H�Q�K�K�K�K�K�	� 	r   c                  �&