a �DOgs �@s.dZddlZGdd�d�Zdd�Zdd�ZdS) z� Basic subprocess implementation for POSIX which only uses os functions. Only implement features required by setup.py to build C extension modules when subprocess is unavailable. setup.py is not used on Windows. �Nc@seZdZddd�Zdd�ZdS)�PopenNcCs||_||_d|_dS)N)�_cmd�_env� returncode)�self�cmd�env�r �'/usr/lib64/python3.9/_bootsubprocess.py�__init__ szPopen.__init__c Cs�t��}|dkrfzF|jdur6t�|jd|j|j�nt�|jd|j�Wt�d�q�t�d�0nt�|d�\}}t�|�|_ |j S)Nr�) �os�forkr�execver�execv�_exit�waitpid�waitstatus_to_exitcoder)r�pid�_�statusr r r �waits  z Popen.wait)N)�__name__� __module__� __qualname__r rr r r r r s rcCs�g}dD]2\}}tt|�t|�d�D]}|�t|��q&q|�d�d�|�}t|ttf�rd|}nt|t�rv|g}ndS|D]8}t|t�s�dS|s�dS|D]}||vr�dSq�q~dS)N))�a�z)�A�Z)�0�9r z./-�FT) �range�ord�append�chr�join� isinstance�tuple�list�str)rZ safe_chars�first�lastZchZ check_strs�argr r r � _check_cmd$s(      r.cKs|rtt|���t|�s&td|����d}t|t�s>d�|�}|�d|��}z�t�|�}t� |�}|rztd|�d|����z6t |d��}|� �}Wd�n1s�0YWnt y�d}Yn0Wzt� |�Wnty�Yn0n&zt� |�Wnt�yYn00|S) Nzunsupported command: zcheck_output.tmp� z >zCommand z returned non-zero exit status �rb�)�NotImplementedError�reprr.� ValueErrorr'r*r&r �systemr�open�read�FileNotFoundError�unlink�OSError)r�kwargsZ tmp_filenamer�exitcode�fp�stdoutr r r � check_outputBs:      � *   �r?)�__doc__r rr.r?r r r r �s