403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.217.51
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python315/Lib/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python315/Lib/test/__pycache__/test_subprocess.cpython-315.opt-1.pyc
R
>lqj]�c��]PHs]QHGs]QHGs]QHGs]QHGs]QHGs]QHGs]QHG	s	]QH(Gs]PH0s]PH4s
]PH8s]PH<s]PH@s]PHDs]PHHs]PHLs]PHPs]PHTs]PHXs]PH\s]PH`s]PHds]PHhs]PHls]PHps]PHts]PHxs]PH|s]Q	H�G!s!]PH�s"]PH�s$]PH�s%]PH�s&]PH�s'\OP%c\ORQ
2g\OT%f\ORQ2g\
OVQ6Hs,\,%cQ
s-LPs-Q0s.\/\0\11s2\
OfQQ1r4Qs5QQ\Ol2s7QQ\82s9QQ\Ot2s;QQ\72s<QQ\72s=Qs>\O~\,Q2QQ\722s@\O�\,Q2Q Q!\722sBQ"Q#\Ol2sC\O�\D\Q$2Q%2Q&Q'\<22sE\O�\,Q(2Q)Q*\722sFQ+Q,\72sGQ-Q.\72sH\IQ/6Xc\O�2P!P!\#cPs"CK�h9h\#cPs$CK�h9h\#cPs%CK�h9h\#cPs&CK�h9hPs'CK�9h)1�)�mock)�support)�check_sanitizer)�
import_helper)�	os_helper)�
strace_helper)�warnings_helper)�assert_python_ok)�FakePathztest is not helpful for PGOztest module requires subprocess�win32z@import msvcrt; msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY);�-c�passc���[OQ2oUeP![OU[O2%c.[
OU,2O]6XcU1rP!P!P!)�true)	�shutil�which�os�access�X_OK�
subprocess�run�
returncode�ZERO_RETURN_CMD)�
shell_trues �)C:\Python315\\Lib\test\test_subprocess.py�setUpModulerPsX�����f�%�J����
�	�	�*�b�g�g�&�&����
�|�$�/�/�1�4�%�-��	5�	'�c�.`�\sQs]ZsnQsQsQsUsP!)�BaseTestCasec�2�[O2P!�N)r�
reap_children��selfs&r�setUp�BaseTestCase.setUp[s��	���rc�$�[%f^[OFDoUO2J	[O2UO[OQ2UO
2[O2P!)zsubprocess._active not empty)	�	mswindowsr�_active�wait�_cleanup�assertFalse�
doCleanupsrr!)r#�insts& r�tearDown�BaseTestCase.tearDown`s^���y�"�*�*���	�	��+����!�����"�"�$B�
�	
�������r���__name__�
__module__�__qualname__�__firstlineno__r$r.�__static_attributes__�__classdictcell__��
__classdict__s@rrrZs���� �

 �
 rrc��\sQs]msQsP!)�PopenTestExceptionr0)r2r3r4r5r6r0rrr;r;ms��rr;c�,`�\sQs]qsnQsQsQsUsP!)�PopenExecuteChildRaisesz]Popen subclass for testing cleanup of subprocess.PIPE filehandles when
_execute_child fails.
c��[Q2g)zForced Exception for Test)r;)r#�args�kwargss&*,r�_execute_child�&PopenExecuteChildRaises._execute_childus�� �!<�=�=rr0)r2r3r4r5�__doc__rAr6r7r8s@rr=r=qs�����>�>rr=c�4	`�\sQs]ysnQsQsQsQsQsQs	Qs
QsQ	sQ
s
QsQsQ
sQsQsQsQsQsQsQsQsQsQsQsQsQsQsQsQs \!OD\#Q2Q2s$\!OD\#Q2Q 2s%\!OD\#Q2Q!2s&Q"s'Q#s(Q$s)Q%s*Q&s+Q's,\!OD\#Q(2Q)2s-\!OD\#Q(2Q*2s.Q+s/\!OD\0Ob\0Od6gQ,2Q-2s3\!OD\0Ob\0Od6gQ,2\!OD\4Oj2Q.2Q/22s6Q0s7Q1s8Q2s9Q3s:Q4s;Q5s<Q6s=Q7s>Q8s?Q9s@Q:sAQ;sBQ<sCQ=sDQ>sEQ?sF\!O�\H9%c
\I\HQ@2QA2QB2sJ\!O�\H9%c
\I\HQ@2QA2QC2sKQDsL\!O�\0O�QE6HQF2QG2sN\!OD\0O�QE6HQH2\!OD\4O�QI2]6HQJ2\!OD\PP	QK5QL2QM222sQ\!OD\4O�QI2]6HQN2\!OD\PP	QK5QL2QO22sRQPsSQQsT\!O�\0O�QE6HQF2QR2sUQSsVQTsWQUsXQVsYQWsZQXs[QYs\QZs]Q[s^Q\s_Q]s`Q^saQ_sbQ`scQasdQbseQcsfQdsgQeshQfsiQgsjQhskQislQjsmQksnQlsoQmspQnsqQosrQpssQqstQrsu\vO�Qs2Qt2sxQusyQvszQws{Qxs|Qys}Qzs~Q{sQ|s�\!O�\I\�Q}2Q~2\!O�\I\�Q2Q�2\!O�\I\�Q�2Q�2Q�222s�\!O�\�COCOQ�\�CO2*2Q�2Q�2s�\!OD\#Q�2Q�2s�\!OD\#Q�2Q�2s�Q�s�\!O�\I\�Q�2Q�2Q�2s�Q�s�Q�s�Us�P!)��ProcessTestCasec��[O[[O[O[OQ5oUO	UO
[O2UO	UO[O2UO	UO[O2UO
O2UOO2UOO2UO2P!SO
O2SOO2SOO2SO2h9h)��stdin�stdout�stderr)r�Popenr�PIPE�assertIsInstancerH�io�BufferedIOBaserIrJ�closer)�r#�ps& r�test_io_buffered_by_default�+ProcessTestCase.test_io_buffered_by_default{s������_�#-�?�?�:�?�?�$.�O�O�
5��	��!�!�!�'�'�2�+<�+<�=��!�!�!�(�(�B�,=�,=�>��!�!�!�(�(�B�,=�,=�>�
�G�G�M�M�O�
�H�H�N�N��
�H�H�N�N��
�F�F�H��
�G�G�M�M�O�
�H�H�N�N��
�H�H�N�N��
�F�F�H�s�A>D)�)A F	c��[O[[O[O[O]Q5oUO	UO
[O2UO	UO[O2UO	UO[O2UO
O2UOO2UOO2UO2P!SO
O2SOO2SOO2SO2h9h)r)rHrIrJ�bufsize)rrKrrLrMrHrN�	RawIOBaserIrJrPr)rQs& r�test_io_unbuffered_works�(ProcessTestCase.test_io_unbuffered_works�s������_�#-�?�?�:�?�?�$.�O�O�Q�
@��	��!�!�!�'�'�2�<�<�8��!�!�!�(�(�B�L�L�9��!�!�!�(�(�B�L�L�9�
�G�G�M�M�O�
�H�H�N�N��
�H�H�N�N��
�F�F�H��
�G�G�M�M�O�
�H�H�N�N��
�H�H�N�N��
�F�F�H�s�A>D*�*A F
c�z�[O[OQQ,2oUO	U]/2P!�r�import sys; sys.exit(47)�r�call�sys�
executable�assertEqual�r#�rcs& r�
test_call_seq�ProcessTestCase.test_call_seq�s0��
�_�_�c�n�n�d�8�:�;������R� rc��UO[O[O[O
QQ,QQ5P!)r�while True: pass皙�����?��timeout)�assertRaisesr�TimeoutExpiredr^r_r`r"s&r�test_call_timeout�!ProcessTestCase.test_call_timeout�s7��
	
���*�3�3�Z�_�_��>�>�4�1C�D�"%�	�	'rc���[O[OQQ,PQ5UO	Q2[O[OQQ,]Q5UO	Q2P![O
c&oSO
Q[S22Po=KrPo=hh9h[O
c'oSO
Q[S22Po=P!Po=hh9h)rzimport time;time.sleep(9)riz,Expected TimeoutExpired exception not raisedz
-1 secondsz	0 seconds)rrr_r`�failrl�assertIn�str)r#�es& r�test_timeout_exception�&ProcessTestCase.test_timeout_exception�s���	F��N�N�C�N�N�D�2M�N�Z\�]�
�I�I�D�E�	F��N�N�C�N�N�D�2M�N�Z[�\�
�I�I�D�E���(�(�	0��M�M�,��A��/�/��	0���(�(�	/��M�M�+�s�1�v�.�.��	/�s:�)A:�)B7�:B4�B4�B/�/B4�7C2�C2�C-�-C2c�`�[O[2oUOU]2P!�r)r�
check_callrrarbs& r�test_check_call_zero�$ProcessTestCase.test_check_call_zero�s"��
�
"�
"�?�
3������Q�rc�(�UO[O29^tt^2o[O[O
QQ,2PPP2UO
WOO]/2P!)%fhK89hr[)	rkr�CalledProcessErrorrxr_r`ra�	exceptionr�r#�cs& r�test_check_call_nonzero�'ProcessTestCase.test_check_call_nonzero�sd��
�
�
�z�<�<�
=�
=���!�!�3�>�>�4�#=�#?�
@�>�	
������/�/��4�>�
=���(B�B	�
B	c���[O[OQQ,2oUO	QU2UO[Q29^tt^2[O,PQ5PPP2UO[Q29^tt^2[O,P
Q5PPP2P!)%fhKQ9h)%fhP!9h)r�
print('BDFL')�BDFLz2stdout argument not allowed, it will be overridden�rIz1check argument not allowed, it will be overridden��check)r�check_outputr_r`rq�assertRaisesRegex�
ValueError�r#�outputs& r�test_check_output�!ProcessTestCase.test_check_output�s����(�(������7�9���
�
�g�v�&�
�
#�
#�J�D�F�F��#�#�B�t�4�F��
#�
#�J�C�E�E��#�#�B�e�4�E�E�	F�F��E�E�E�s$�B;�C�;C	�C	�C	�C	c�(�UO[O29^tt^2o[O[O
QQ,2PPP2UO
WOO]2P!)%fhK89h)rzimport sys; sys.exit(5))	rkrr|r�r_r`rar}rr~s& r�test_check_output_nonzero�)ProcessTestCase.test_check_output_nonzero�sc��
�
�
�z�<�<�
=�
=���#�#��^�^�T�+D�E�
G�>�	
������/�/��3�>�
=�r�c��[O[OQQ,[OQ5oUOQU2P!)r�$import sys; sys.stderr.write('BDFL')�rJr�)rr�r_r`�STDOUTrqr�s& r�test_check_output_stderr�(ProcessTestCase.test_check_output_stderr�s:���(�(�����'M�N�!�(�(�*��	
�
�
�g�v�&rc�"�[O2oUOUO2UO	Q2UO]2[O[OQQ,UQ5oUOQU2P!)�pearr�6import sys; sys.stdout.write(sys.stdin.read().upper())�rH�PEAR)�tempfile�
TemporaryFile�
addCleanuprP�write�seekrr�r_r`rq)r#�tfr�s&  r�test_check_output_stdin_arg�+ProcessTestCase.test_check_output_stdin_arg�sl��
�
#�
#�
%��������!�
�����
����
��(�(�����I�K����	
�
�
�g�v�&rc�~�[O[OQQ,QQ5oUO	QU2P!)rr�r���inputr��rr�r_r`rqr�s& r�test_check_output_input_arg�+ProcessTestCase.test_check_output_input_arg�s7���(�(�����I�K����	
�
�
�g�v�&rc�~�[O[OQQ,PQ5oUO	QU2P!)z<input=None has a legacy meaning of input='' on check_output.r�3import sys; print('XX' if sys.stdin.read() else '')r�sXX�rr�r_r`�assertNotInr�s& r�test_check_output_input_none�,ProcessTestCase.test_check_output_input_none�s9���(�(�����F�H����	
�����'rc��[O[OQQ,PP	Q5oUO	QU2P!)rr�)r��text�XXr�r�s& r�!test_check_output_input_none_text�1ProcessTestCase.test_check_output_input_none_text�s;���(�(�����F�H���'��	
����v�&rc��[O[OQQ,PP	Q5oUO	QU2P!)rr�)r��universal_newlinesr�r�r�s& r�/test_check_output_input_none_universal_newlines�?ProcessTestCase.test_check_output_input_none_universal_newlines�s;���(�(�����F�H��t�5��	
����v�&rc��[O[OQQ,PQQQ5oUO	QU2P!)rzprint('foo')�utf-8�ignore)r��encoding�errors�foor�r�s& r�,test_check_output_input_none_encoding_errors�<ProcessTestCase.test_check_output_input_none_encoding_errorss7���(�(�����~�6��W�X�?��	
�
�
�e�V�$rc�d�UO[29^tt^2o[O[O
QQ,[OQ5oUOQ2PPP2UOQWOO]*2P!)%fhK?9h)r�print('will not be run')r�z-Expected ValueError when stdout arg supplied.rI)rkr�rr�r_r`rIrprqr}r?�r#rr�s&  r�test_check_output_stdout_arg�,ProcessTestCase.test_check_output_stdout_argsw��
�
�
�z�
*�
*�a��,�,��^�^�T�+E�F��:�:�'�F�
�I�I�E�F�	+�
	
�
�
�h���� 0� 0�� 3�4�+�
*�s�A	B�B/	�(B/	c�H�[O2oUOUO2UO	Q2UO]2UO
[29^tt^2o[O[OQQ,UQQ5oUOQ2PPP2UOQWOO]*2UOQUOO]*2P!)%fhKl9h)r�rr��hare�rHr��7Expected ValueError when stdin and input args supplied.rHr�)r�r�r�rPr�r�rkr�rr�r_r`rprqr}r?�r#r�rr�s&   r�&test_check_output_stdin_with_input_arg�6ProcessTestCase.test_check_output_stdin_with_input_args���
�
#�
#�
%��������!�
�����
����
�
�
�
�z�
*�
*�a��,�,��^�^�T�+E�F��G�-�F�
�I�I�O�P�	+�
	
�
�
�g�q�{�{�/�/��2�3��
�
�g�q�{�{�/�/��2�3�
+�
*�s�1<D�D!	�D!	c���UO[O29^tt^2o[O[O
QQ,QQ5oPPP2P!)%fhP!9h)r�import time; time.sleep(3600)rhri)rkrrlr�r_r`r�s&  r�test_check_output_timeout�)ProcessTestCase.test_check_output_timeout#sN��
�
�
�z�8�8�
9�
9�Q��,�,��^�^�T�4�6��!�F�:�
9�
9�
9�s�*A�A.	�&A.	c���[OO2oQUQ$[O[
OQQ,UQ5oUOU]2P!)�banana�FRUITrz5import sys, os;sys.exit(os.getenv("FRUIT")=="banana")��env)r�environ�copyrr^r_r`ra)r#�newenvrcs&  r�test_call_kwargs� ProcessTestCase.test_call_kwargs+sT�������"��"��w��
�_�_�c�n�n�d�G�H�"(�)��	
����Q�rc���[O29^tt^2oUO[[O
]Q5[O
OOOo],U]**oUO[[O
,UN3PPP2UOWO2P2P!)%fhK29h)�)�invalid_arg_name)r�captured_stderrrk�	TypeErrorrrK�__init__�__code__�co_argcountra�getvalue)r#�s�argcount�
too_many_argss&   r�test_invalid_args�!ProcessTestCase.test_invalid_args5s����
$�
$�
&�
&�!����i��)9�)9�A��N�!�'�'�0�0�9�9�E�E�H��C�8�a�<�0�M����i��)9�)9�J�M�J�	'�
	
�������r�*�'�
&�s�BC�C'	� C'	c��[O[OQQ,[O[OQ5oUOUOO2UOUOO2UO2UOUOP2P!)r�print("banana")�rIrJ)rrKr_r`rLr�rIrPrJr)rarHrQs& r�test_stdin_none�ProcessTestCase.test_stdin_none?ss�����c�n�n�d�4E�F� *���
���
I����������'���������'�	����������$�'rc���Qo[O[OQU,[O[OQ5oUOUOO2UOUOO2UO2vq4UOUO]U2UOUO2Q2P!)z�import sys; from subprocess import Popen, PIPE;p = Popen([sys.executable, "-c", "print('test_stdout_none')"],          stdin=PIPE, stderr=PIPE);p.wait(); assert p.stdout is None;rr�stest_stdout_none�
rrKr_r`rLr�rIrPrJ�communicaterar�rstrip�r#�coderR�out�errs&    r�test_stdout_none� ProcessTestCase.test_stdout_noneHs���5��
���c�n�n�d�D�9�$.�O�O�J�O�O�
M����������'���������'��=�=�?���������q�#�.��������':�;rc��[O[OQQ,[O[OQ5oUOUOO2UOUOO2UO2UOUOP2P!)rr��rHrI)rrKr_r`rLr�rIrPrHr)rarJrQs& r�test_stderr_none� ProcessTestCase.test_stderr_none_ss�����c�n�n�d�4E�F�)���z���
H����������'�������
�
�&�	����������4�(rc��UQ,*o[OU1-U@oUO2UO]/UO2P!�r\)rrKr)rar)r#�pre_argsr@r?rRs&&,  r�_assert_python�ProcessTestCase._assert_pythonhsD���5�6�6�����T�,�V�,��	��������Q�\�\�*rc���[OO[OO[O
2Q2oUO
UQ,[O
Q5P!��doesnotexistr�r`)r�path�join�dirnamer_r`r�r#rs& r�test_executable�ProcessTestCase.test_executablepsH���w�w�|�|�B�G�G�O�O�C�N�N�$C�$2�4�����\�4�0�S�^�^��Lrc��[OO[OO[O
2Q2oUO
UQ,[O[O
2Q5P!r)rrrr	r_r`r�fsencoder
s& r�test_bytes_executable�%ProcessTestCase.test_bytes_executable{sU���w�w�|�|�B�G�G�O�O�C�N�N�$C�$2�4�����\�4�0�')�{�{�3�>�>�'B�	�	Drc��[OO[OO[O
2Q2oUO
UQ,[[O
2Q5P!r)rrrr	r_r`rr
r
s& r�test_pathlike_executable�(ProcessTestCase.test_pathlike_executable�sQ���w�w�|�|�B�G�G�O�O�C�N�N�$C�$2�4�����\�4�0�'/����'?�	�	Arc��[OQ,oUOU2UO[UOU[
]*Q5P!)rr)r_r`rrk�NONEXISTING_ERRORS�NONEXISTING_CMD)r#rs& r� test_executable_takes_precedence�0ProcessTestCase.test_executable_takes_precedence�sI���N�N�D�)�����H�%����,��-�-�x�%4�Q�%7�	�	9rz"executable argument replaces shellc�L�UO,[OP	Q5P!�T)r`�shell)rr_r`r"s&r�test_executable_replaces_shell�.ProcessTestCase.test_executable_replaces_shell�s��	
���B�3�>�>���Frc�t�UO,[O[O2P	Q5P!r)rrrr_r`r"s&r�$test_bytes_executable_replaces_shell�4ProcessTestCase.test_bytes_executable_replaces_shell�s)�����B�2�;�;�s�~�~�+F�"&�	�	(rc�^�UO,[[O2P	Q5P!r)rr
r_r`r"s&r�'test_pathlike_executable_replaces_shell�7ProcessTestCase.test_pathlike_executable_replaces_shell�s%�����B�8�C�N�N�+C�"&�	�	(rc��[OU29^tt^2[O2ttPPP2!)%fhP!9hr )r�
change_cwdr�getcwd)r#�cwds&&r�_normalize_cwd�ProcessTestCase._normalize_cwd�s-���
!�
!�#�
&�
&��9�9�;�'�
&�
&�
&�s�A�A	�	A	c��[OO[O2o[OOU2!r )rr�realpathr_r`�split)r#�python_paths& r�_split_python_path�"ProcessTestCase._split_python_path�s-���g�g�&�&�s�~�~�6���w�w�}�}�[�)�)rc��[OUQQ,1Q[O-U@oUOUOO
2UO
2UO]/UO2[OOoUOUU2UUOO2O222P!)rzcimport os, sys; buf = sys.stdout.buffer; buf.write(os.getcwd().encode()); buf.flush(); sys.exit(47)rI)rrKrLr�rIrPr)rarrr�normcase�read�decode)r#�expected_cwd�
python_argr@rRr1s&&&,  r�_assert_cwd�ProcessTestCase._assert_cwd�s���
���j�$�-�.�
(�&0�_�_�

(�!'�
(��	
��������'�	��������Q�\�\�*��7�7�#�#������,�/�!�!�(�(�-�-�/�"8�"8�":�;�	=rc��[O2oUOU2oUOU[O
UQ5P!��r')r��
gettempdirr(r6r_r`�r#�temp_dirs& r�test_cwd�ProcessTestCase.test_cwd�s9���&�&�(���&�&�x�0������3�>�>�x��@rc��[O2oUOU2oUOU[O
[OU2Q5P!r9)r�r;r(r6r_r`rrr<s& r�test_cwd_with_bytes�#ProcessTestCase.test_cwd_with_bytes�sB���&�&�(���&�&�x�0������3�>�>�r�{�{�8�7L��Mrc��[O2oUOU2oUOU[O
[
U2Q5P!r9)r�r;r(r6r_r`r
r<s& r�test_cwd_with_pathlike�&ProcessTestCase.test_cwd_with_pathlike�s>���&�&�(���&�&�x�0������3�>�>�x��7I��Jrz"pending resolution of issue #15533c	���UO2vq[OO[OU2o[
O29^tt^2oUO[[OU,2UO[[OU,UQ5UOU2oUOVUQ5PPP2P!)%fhP!9hr9�
r.rrr�curdirr�temp_cwdrk�FileNotFoundErrorrrKr(r6)r#�
python_dir�python_base�
rel_python�	wrong_dirs&    r�test_cwd_with_relative_arg�*ProcessTestCase.test_cwd_with_relative_arg�s���#'�"9�"9�";��
��W�W�\�\�"�)�)�[�9�
�
�
�
�
!�
!�Y�
���/��1A�1A�)�l�
,����/��1A�1A�)�l�	�
�
;��,�,�Z�8�J����Z���D�"�
!�
!�
!�s�A3C�C-	�%C-	c
���UO2vq[OO[OU2oQo[
O29^tt^2oUO[[OU,UQ5UO[[OU,UUQ5UOU2oUOVUUQ5PPP2P!)%fhP!9h)�somethingyoudonthaver�r`r'rG)r#rKrLrM�doesntexistrNs&     r�!test_cwd_with_relative_executable�1ProcessTestCase.test_cwd_with_relative_executable�s���#'�"9�"9�";��
��W�W�\�\�"�)�)�[�9�
�,��
�
�
�
!�
!�Y�
���/��1A�1A�*�m�
�
�
D����/��1A�1A�*�m�
�"+�
�
-��,�,�Z�8�J����Z��!+�
�
-�"�
!�
!�
!�s�!A7C"�"C3	�+C3	c	���UO2vq[OOV2o[OO[OU2o[
O29^tt^2oUO[[OU,UQ5UOU2oUOVSUQ5PPP2P!)%fhP!9hr9)
r.rrrrHrr=rkrJrrKr(r6)r#rKrL�
abs_pythonrMrNs&     r�test_cwd_with_absolute_arg�*ProcessTestCase.test_cwd_with_absolute_arg�s���#'�"9�"9�";��
��W�W�\�\�*�:�
��W�W�\�\�"�)�)�[�9�
�
�
�
�
!�
!�Y�
���/��1A�1A�)�l�	�
�
;��+�+�I�6�I����Y�	��B�
"�
!�
!�
!�s�>A
C�C&	�C&	zTest is not venv-compatiblec��UO2vqUOU2oUOUQ[OUQ5P!)rRrS)r.r(r6r_r`)r#rKrLs&  r�test_executable_with_cwd�(ProcessTestCase.test_executable_with_cwdsG��#'�"9�"9�";��
��(�(��4�
�����%;�$'�N�N�
�	�	Drz#need an installed Python. See #7774c�r�UO[O2Q[OQ5P!)rRr)r6rr&r_r`r"s&r�test_executable_without_cwd�+ProcessTestCase.test_executable_without_cwds)��	
�������&<�$'�N�N�	�	4rc�8�[O[OQQ,[OQ5oUO
O
Q2UO
O2UO2UOUO]2P!)r�0import sys; sys.exit(sys.stdin.read() == "pear")r�r�)rrKr_r`rLrHr�rPr)rarrQs& r�test_stdin_pipe�ProcessTestCase.test_stdin_pipesf�����c�n�n�d�K�M�(�o�o�
/��	
���
�
�g��	���
�
��	����������q�)rc��[O2oUOUO2UO	2o[
OUQ2[
OU]]2[O[OQQ,UQ5oUO2UOUO]2P!�r�rrbr�)r�r�r�rP�filenorr��lseekrrKr_r`r)rar�r#r��drRs&   r�test_stdin_filedes�"ProcessTestCase.test_stdin_filedes s���
�
#�
#�
%��������!��I�I�K��
����G��
����A�q�����c�n�n�d�K�M� �
"��	
����������q�)rc�V�[O2oUOUO2UO	Q2UO]2[O[OQQ,UQ5oUO2UOUO]2P!rf)
r�r�r�rPr�r�rrKr_r`r)rar�r#r�rRs&  r�test_stdin_fileobj�"ProcessTestCase.test_stdin_fileobj-sz��
�
#�
#�
%��������!�
�����
����
����c�n�n�d�K�M�!�
#��	
����������q�)rc��[O[OQQ,[OQ5oU9^tt^2UOUOO2Q2PPP2P!)%fhP!9h�r�&import sys; sys.stdout.write("orange")r��orange�rrKr_r`rLrarIr2rQs& r�test_stdout_pipe� ProcessTestCase.test_stdout_pipe9sW�����c�n�n�d�B�D� *���
1���Q����Q�X�X�]�]�_�i�8��Q�Q�Q���+A8�8B		�B		c�x�[O2oUOUO2UO	2o[
O[OQQ,UQ5oUO2[OU]]2UO[OUQ2Q2P!)rrsr��rt�r�r�r�rPrgrrKr_r`r)rrhrar2ris&   r�test_stdout_filedes�#ProcessTestCase.test_stdout_filedesAs���
�
#�
#�
%��������!��I�I�K�����c�n�n�d�B�D� !�
#��	
����
����A�q���������D�)�9�5rc�<�[O2oUOUO2[O
[OQQ,UQ5oUO2UO]2UOUO2Q2P!rr�r�r�r�rPrrKr_r`r)r�rar2rns&  r�test_stdout_fileobj�#ProcessTestCase.test_stdout_fileobjMsp��
�
#�
#�
%��������!����c�n�n�d�B�D� "�
$��	
����
����
��������I�.rc��[O[OQQ,[OQ5oU9^tt^2UOUOO2Q2PPP2P!)%fhP!9h�r�*import sys; sys.stderr.write("strawberry")r��
strawberry)rrKr_r`rLrarJr2rQs& r�test_stderr_pipe� ProcessTestCase.test_stderr_pipeXsW�����c�n�n�d�F�H� *���
1���Q����Q�X�X�]�]�_�m�<��Q�Q�Q�rxc�x�[O2oUOUO2UO	2o[
O[OQQ,UQ5oUO2[OU]]2UO[OUQ2Q2P!)rr�r�rzr�r{ris&   r�test_stderr_filedes�#ProcessTestCase.test_stderr_filedes`s���
�
#�
#�
%��������!��I�I�K�����c�n�n�d�F�H� !�
#��	
����
����A�q���������D�)�=�9rc�<�[O2oUOUO2[O
[OQQ,UQ5oUO2UO]2UOUO2Q2P!r�rrns&  r�test_stderr_fileobj�#ProcessTestCase.test_stderr_fileobjlsp��
�
#�
#�
%��������!����c�n�n�d�F�H� "�
$��	
����
����
��������M�2rc�8�[O[OQQ,[O[OQ5oUO2vq#UO
UQ2UO
UQ2UO
UO]2P!)rz�import sys, subprocess;rc = subprocess.call([sys.executable, "-c",    "import sys;"    "sys.stderr.write('42')"],    stderr=subprocess.STDOUT);sys.exit(rc)r�s42r�rrKr_r`rLr�rar�r#rRrIrJs&   r�,test_stderr_redirect_with_no_stdout_redirect�<ProcessTestCase.test_stderr_redirect_with_no_stdout_redirectwsy��
���c�n�n�d�-�.�%/�O�O�$.�O�O�
5�������������'������%�������q�)rc�6�[O[OQQ,[O[O
Q5oU9^tt^2UO
UOO2Q2PPP2P!)%fhP!9h�r�Rimport sys;sys.stdout.write("apple");sys.stdout.flush();sys.stderr.write("orange")r�sappleorange)	rrKr_r`rLr�rarIr2rQs& r�test_stdout_stderr_pipe�'ProcessTestCase.test_stdout_stderr_pipe�sc�����c�n�n�d�;�<�
%/�O�O�$.�$5�$5�

7���Q����Q�X�X�]�]�_�n�=��Q�Q�Q�s�+B�B	�B	c�>�[O2oUOUO2[O
[OQQ,UUQ5oUO2UO]2UOUO2Q2P!r�rrns&  r�test_stdout_stderr_file�'ProcessTestCase.test_stdout_stderr_file�sv��
�
#�
#�
%��������!����c�n�n�d�;�<�
%'�$&�

(��	
����
����
��������N�3rc���Qo[O[OQU,[O[OQ5oUOUOO2UOUOO2UO2vq4UOUO]U2UOUO2Q2P!)z�import sys, subprocess; rc = subprocess.call([sys.executable, "-c",     "import os, sys; sys.exit(os.write(sys.stdout.fileno(), b'test with stdout=1'))"], stdout=1); assert rc == 18rr�stest with stdout=1r�r�s&    r�test_stdout_filedes_of_stdout�-ProcessTestCase.test_stdout_filedes_of_stdout�s���"��

���c�n�n�d�D�9�$.�O�O�J�O�O�
M����������'���������'��=�=�?���������q�#�.��������'<�=rc���[O[OQQ,[OQ5oUO2UO
UOP2P!)rz'for i in range(10240):print("x" * 1024)r�)rrKr_r`�DEVNULLr)rarIrQs& r�test_stdout_devnull�#ProcessTestCase.test_stdout_devnull�sN�����c�n�n�d�2�3�&0�%7�%7�
9��	
����������4�(rc���[O[OQQ,[OQ5oUO2UO
UOP2P!)rz=import sys
for i in range(10240):sys.stderr.write("x" * 1024)r�)rrKr_r`r�r)rarJrQs& r�test_stderr_devnull�#ProcessTestCase.test_stderr_devnull�sN�����c�n�n�d�=�>�&0�%7�%7�	
9��
	
����������4�(rc���[O[OQQ,[OQ5oUO2UO
UOP2P!)rzimport sys;sys.stdin.read(1)r�)rrKr_r`r�r)rarHrQs& r�test_stdin_devnull�"ProcessTestCase.test_stdin_devnull�sN�����c�n�n�d�2�3�%/�$6�$6�
8��	
����������$�'r�F_GETPIPE_SZz%fcntl.F_GETPIPE_SZ required for test.c��[O2vq[OU[O2o[OU2[OU2U]*o[
O2oVE6c[OQ2g[O[OQQ,[O[O[OUQ5oUOUOUO 1FDFoUO#[OUO%2[O2U2JH	UOO'Q2UOO	2UOO	2UO O	2UO)2UO+2P![OS2[OS2h9hSO)2SO+2h9h)�z+default pipesize too small to perform test.r�Qimport sys; sys.stdin.read(); sys.stdout.write("out"); sys.stderr.write("error!")�rHrIrJ�pipesizer�)r�pipe�fcntlr�rPr�get_pagesize�unittest�SkipTestrrKr_r`rLrHrIrJrargr��killr))r#�test_pipe_r�test_pipe_w�pipesize_defaultr��pagesize_defaultrR�fifos&       r�test_pipesizes�ProcessTestCase.test_pipesizes�s���$&�7�7�9� ��	"�$�{�{�;��8J�8J�K���H�H�[�!��H�H�[�!�#�q�(��"�/�/�1���&��#�#�=�?�
?����
�^�^�T�*�
+��/�/�*�/�/��?�?�X�
7��	����!�(�(�A�H�H�5��� � ��K�K����
�u�/A�/A�B���6�
�G�G�M�M�'�"�
�G�G�M�M�O�
�H�H�N�N��
�H�H�N�N��
�F�F�H�
�F�F�H��7
�H�H�[�!��H�H�[�!��2
�F�F�H�
�F�F�H�s�%G5�<CH&�5.H#�&"Ic��[O[OQQ,[O[O[OPQ5oS9^tt^2[
O2vq#[OU[O2o[OU[O2o[
OU2[
OU2UO[OUOO2[O2U2UO[OUOO2[O2U2UO[OUOO2[O2U2UO2PPP2P![
OS2[
OS2h9hSO2h9h)%fhP!9h)rr�r�)rrKr_r`rLrr�r�r�rPrarHrgrIrJr�)r#�proc�fp_r�fp_w�default_read_pipesize�default_write_pipesizes&     r�test_pipesize_default�%ProcessTestCase.test_pipesize_default�s}�����
�^�^�T�*�
+��/�/�*�/�/��?�?�R�1���T�
��W�W�Y�
��#�,1�K�K��e�>P�>P�,Q�)�-2�[�[��u�?Q�?Q�-R�*��H�H�T�N��H�H�T�N�� � ��K�K��
�
� 1� 1� 3�U�5G�5G�H�)�+�� � ��K�K���� 2� 2� 4�e�6H�6H�I�*�,�� � ��K�K���� 2� 2� 4�e�6H�6H�I�*�,��	�	��-�T���H�H�T�N��H�H�T�N���	�	���-�T�T�sD�"H:�$H%�<A
G4�DH%�H:�4.H"�"H%�%H7�7H:�:I	�I	c�P�[OO2oQUQ$[O[
OQQ,[OUQ59^tt^2oUO2vq4UOUQ2PPP2P!)%fhP!9h)�oranger�r�2import sys,os;sys.stdout.write(os.getenv("FRUIT"))�rIr�rt)
rr�r�rrKr_r`rLr�ra�r#r�rRrIrJs&    r�test_env�ProcessTestCase.test_envs��������"��"��w��
�
�
�s�~�~�t� F�G�&0�_�_�"(�	*�*�./��]�]�_�N�F����V�Y�/�
*�*�*�*�s�%%B�B%	�B%	rzWindows only issuec�l�[OO2oQUQ$QUQ$QUQ$QUQ$[O,Q
N[O
UQ59^tt^2oUO
2vq4UOUO2Q	2PPP2P!)%fhP!9h)�cherry�fRUit�lemon�fruitr�r�r��frUitr�sfrUit=banana��CMDz/c�SETr�)	rr�r�rrKrLr�ra�strip)r#r�rRrI�_s&    r�test_win32_duplicate_envs�)ProcessTestCase.test_win32_duplicate_envs%s��������"��"��w��!��w��"��w��"��w��
�
�
�;�%/�_�_�"(�*�*�-.��
�
��I�F����V�\�\�^�_�=�	*�*�*�*�s�%3B"�"B3	�+B3	z#cannot test an empty env on Windows�Py_ENABLE_SHAREDzEThe Python shared library cannot be loaded with an empty environment.)�addressz)AddressSanitizer adds to the environment.c	��Qo[O[OQQ,[O-Q59^tt^2oUO2vq4[
UO22oUOU[2STt,tFDoUU2%cJUMJ	ooUOU,2PPP2P!ttoh)%fhP!9h)z+Verify that env={} is as empty as possible.c��QU79%f9QU79%f,UQ6H9%fUOQ29%fUQ6H!)z:Determine if an environment variable is under our control.�	VERSIONER�__CF�
LD_PRELOAD�SANDBOX�LC_CTYPE)�
startswith)�ns&r�is_env_var_to_ignore�<ProcessTestCase.test_empty_env.<locals>.is_env_var_to_ignore>sZ��
 �1�$�$�$��!��$�$���%�$�$�)*���i�)@�$�$���O�
%rrz)import os; print(list(os.environ.keys()))r�)rrKr_r`rLr��evalr�rM�listra)r#r�rRrIrJ�child_env_names�ks&      r�test_empty_env�ProcessTestCase.test_empty_env4s���	%��
�
�s�~�~�t�J�L�%/�_�_�"�>�>�AB��]�]�_�N�F�"�6�<�<�>�2�O��!�!�/�4�8�*9�?�/�Q�&:�1�&=� !�q�/�O�?����_�b�1�>�>��?�
>�>�>�s+�AC
�
C�!C�'C
�C
�
C	�C	zLThe Python shared library cannot be loaded without some system environments.c	�z�QQ-o[OQQ,o[OQ6Xc,QNo[OU[O
[O
UQ59^tt^2oUO
2vqEUO%cO[O%c9[QUOQQ22[Q	UOQQ22UOUO]2UOUO2Q
2PPP2P!)%fhP!9h)r�r�rz;import sys,os;sys.stdout.write("fruit="+os.getenv("fruit"))r)rIrJr�zSTDOUT:�ascii�replacezSTDERR:sfruit=oranger�)r_r`�platformrrKrLr�rr�verbose�printr3rar�)r#r��cmdrRrIrJs&     r�test_one_environment_variable�-ProcessTestCase.test_one_environment_variableQs����8�$���~�~�t� O�P���<�<�7�"�/�C�
�
�
�c�*�/�/�*�/�/�W]�
^�
^�bc��]�]�_�N�F��|�|�|������i����w�	�!B�C��i����w�	�!B�C����Q�\�\�1�-����V�\�\�^�_�=�
_�
^�
^�
^�s�0$D)�D)�+A4D)�)D:	�2D:	c��[OQ*oUO[29^tt^2[O
UQQ,2PPP2UO[29^tt^2[O
[OQQ,2PPP2P!)%fhK_9h)%fhP!9h)�rr
zpass#)r_r`rkr�rrK)r#r�s& r�test_invalid_cmd� ProcessTestCase.test_invalid_cmdes����n�n�t�#��
�
�
�z�
*�
*����c�4��0�1�+��
�
�z�
*�
*����c�n�n�d�I�>�?�+�
*�	+�
*��+�
*�
*�s#�B'�5(B:�'B7	�0B7	�:C	�C	c�$�[OO2oQUQ$UO[29^tt^2[
O[UQ5PPP2[OO2oQUQ$UO[29^tt^2[
O[UQ5PPP2[OO2oQUQ$UO[29^tt^2[
O[UQ5PPP2[OO2oQUQ$[
O[OQQ	,[
OUQ
59^tt^2oUO2vq4UOUQ2PPP2P!)%fhCKm9h)%fhCK9h)%fhK�9h)%fhP!9h)�cabbagezFRUITVEGETABLEr�zorangeVEGETABLE=cabbager�r�zFRUIT=ORANGEzorange=lemonrz3import sys, os;sys.stdout.write(os.getenv("FRUIT"))r�sorange=lemon)
rr�r�rkr�rrKrr_r`rLr�rar�s&    r�test_invalid_env� ProcessTestCase.test_invalid_envosq�������"��%.��!�"�
�
�
�z�
*�
*����_�&�9�+������"��5��w��
�
�
�z�
*�
*����_�&�9�+������"��!(��~��
�
�
�z�
*�
*����_�&�9�+������"��(��w��
�
�
�s�~�~�t� F�G�&0�_�_�"(�	*�*�./��]�]�_�N�F����V�_�5�
*�*�%+�
*�
*��+�
*�
*��+�
*��*�*�*�sH�G�'G�G+�%G>�G	�G	�G(	� G(	�+G;	�4G;	�>H	�H	c���[OO2oQUQ$UO[29^tt^2[
O[UQ5PPP2[OO2oQUQ$UO[29^tt^2[
O[UQ5PPP2P!)%fhKw9h)%fhP!9h)r�zFRUIT=VEGETABLEr�z==FRUIT)rr�r�rkr�rrKr)r#r�s& r�test_win32_invalid_env�&ProcessTestCase.test_win32_invalid_env�s��������"��$-�� �!�
�
�
�z�
*�
*����_�&�9�+������"��%��y��
�
�
�z�
*�
*����_�&�9�+�
*�+�
*��
+�
*�
*�s$�C�'C!�C	�C	�!C2	�*C2	c���[O[OQQ,[OQ5oUOQ2UO
UO]2P!)rz/import sys;sys.exit(sys.stdin.read() == "pear")r�r�r�rQs& r�test_communicate_stdin�&ProcessTestCase.test_communicate_stdin�sQ�����c�n�n�d�E�F�$.�?�?�
4��	
�
�
�g��������q�)rc���[O[OQQ,[OQ5oUO2vq#UO
UQ2UO
UP2P!)rz)import sys; sys.stdout.write("pineapple")r��	pineapple�rrKr_r`rLr�rar�s&   r�test_communicate_stdout�'ProcessTestCase.test_communicate_stdout�sZ�����c�n�n�d�I�K�$.�O�O�
5���=�=�?��������.������&rc���[O[OQQ,[OQ5oUO2vq#UO
UP2UO
UQ2P!)rz)import sys; sys.stderr.write("pineapple")r�rrr�s&   r�test_communicate_stderr�'ProcessTestCase.test_communicate_stderr�sZ�����c�n�n�d�I�K�$.�O�O�
5���=�=�?��������&������.rc��[O[OQQ,[O[O[OQ5oUOUOO2UOUOO2UOUOO2UOQ2vq#UOUQ2UOUQ2P!)rzNimport sys,os;sys.stderr.write("pineapple");sys.stdout.write(sys.stdin.read())rG�bananar)rrKr_r`rLr�rIrPrJrHr�rar�s&   r�test_communicate� ProcessTestCase.test_communicate�s������c�n�n�d�C�D�$.�?�?�$.�O�O�$.�O�O�

5��	
��������'���������'�������
�
�&��=�=��3��������+������.rc��Qo[U2o[O[OQQ,[O
[O
Q5oUO
UOO2UO
UOO2UOU2vqEUOVA2UOU2P!)sHello, memoryview!rz.import sys; sys.stdout.write(sys.stdin.read())r�)
�
memoryviewrrKr_r`rLr�rIrPrHr�ra�assertIsNone)r#�	test_data�mvrRrIrJs&     r�!test_communicate_memoryview_input�1ProcessTestCase.test_communicate_memoryview_input�s���)�	�
�	�
"�����c�n�n�d�N�P�#-�?�?�$.�O�O�
5��	
��������'�������
�
�&��=�=��,�������+����&�!rc
��]PHo[[QQ2oU]*oSOQ[U2Tt,tFDoQMJ	to2oUO	2o[U2o[O[OQQ,[O[OQ5oUOUOO2UOUOO2UOU2vq�UO!V�Q[#U	28Q	[#U280Q
5UO%U
2P!ttoh)r�PIPE_BUF��iifo0drzIimport sys; data = sys.stdin.buffer.read(); sys.stdout.buffer.write(data)r�zlen(stdout)=z =? len(expected_bytes)=��msg)�array�getattr�select�range�tobytesrrrKr_r`rLr�rIrPrHr�ra�lenr)r#r�pipe_buf�num_elementsr��
test_array�expected_bytesrrRrIrJs&          r�)test_communicate_memoryview_input_nonbyte�9ProcessTestCase.test_communicate_memoryview_input_nonbyte�s��	��6�:�s�3�� �!�|���[�[��5��;N�&O�;N�a�z�;N�&O�P�
�#�+�+�-��
�
�
#�����c�n�n�d�>�?�$.�?�?�$.�O�O�
5��	
��������'�������
�
�&��=�=��,������� ,��F��~�-F�#�n�2E�1G�H�	�	J����&�!��'Ps�
E

c��[O[OQQ,P	[O[O[OQ5oUO[OUOQQQ5UO2vq#UOUQ2UOUO2Q2P!)rz~import sys,os,time;sys.stderr.write("pineapple\n");time.sleep(1);sys.stderr.write("pear\n");sys.stdout.write(sys.stdin.read()))r�rHrIrJr�g333333�?rispineapple
pear
)
rrKr_r`rLrkrlr�ra�encoder�s&   r�test_communicate_timeout�(ProcessTestCase.test_communicate_timeout�s������c�n�n�d�C�D�15�#-�?�?�$.�O�O�$.�O�O�	
5��	
���*�3�3�Q�]�]�H�"%�	�	'��=�=�?��������*��������*>�?rc�(�[O[OQQ,[OQ5oUO[OUOQQ5UO2vq#UO[U2Q2P!)rz�import sys,os,time;sys.stdout.write("a" * (64 * 1024));time.sleep(0.2);sys.stdout.write("a" * (64 * 1024));time.sleep(0.2);sys.stdout.write("a" * (64 * 1024));time.sleep(0.2);sys.stdout.write("a" * (64 * 1024));r�g�������?rii)
rrKr_r`rLrkrlr�rar)r#rRrIr�s&   r�%test_communicate_timeout_large_output�5ProcessTestCase.test_communicate_timeout_large_output�sq�����c�n�n�d�E�F�%/�O�O�	
5��	
���*�3�3�Q�]�]�C��P��m�m�o�������V��m�4rc�<�QQ*o[OQ]Q5oUO]
2UO2]*oQUQ0o[O
[OQU,[O[O[OQ5oPoUO2vqgUO2PoUO]2UO]2oUOP2UOU[UO]�*,2QU8QUOQUO]�*Q	
Q
02Qo	[O 2o
UO#VQ5[O 2U
*
oUO%Q
UQ
Q02UO)UQQUQ
QU	Q02UO+Q2UO2PoUO#2vq�UO[-U2[-U2Q[-U2Q[-U202UOV�2UdUO2UdUO2UO/2UO12P![O&c![O 2S
*
oCKh9hSdSO2SdSO2SO/2SO12h9h)�x)�backlogzKimport os, socket, sys, select; s = socket.create_connection(('127.0.0.1', z�), timeout=9); s.sendall(bytes([os.getpid() & 0xff])); select.select([s], [], [], 9); sys.stdout.buffer.write(sys.stdin.buffer.read())rrGzloopback handshake byte z != low byte of child PID z (z#x�)皙�����?riz6TimeoutExpired not raised. communicate() completed in z.2fzXs, but slow reader stalls for up to 9s. Stdin writing blocked without enforcing timeout.g@zTimeoutExpired raised after z
s; expected ~z2s. Stdin writing blocked without checking timeout.sgoz	Expected z bytes output but got i)z	127.0.0.1r)�socket�
create_server�
settimeout�getsocknamerrKr_r`rL�acceptrP�recvra�bytes�pid�time�	monotonicr�rprl�
assertLess�sendallrr�r))r#�
input_data�server�port�slow_readerrR�connr��	peer_byterj�start�elapsedrIrJs&             r�$test_communicate_timeout_large_input�4ProcessTestCase.test_communicate_timeout_large_inputs����Z�(�
��%�%�&6��B�����"���!�!�#�A�&��
:�:>��@?�
?�	�
���
�^�^�T�;�/��/�/��?�?��?�?�	
$����4	��m�m�o�G�D��L�L�N��F��O�O�A���	�	�!��I��O�O�D�!����Y��q�u�u�t�|�n�(=�*�9�-�8)�)*����r�!�%�%�$�,�r�1B�!�E�
F��G��N�N�$�E�	
3��
�
�j�
�:��.�.�*�U�2���	�	�L��s�m�$G�G�H�
�O�O�G�S�.�w�s�m�=��	�RB�B�
C�

�L�L����J�J�L��D��]�]�_�N�F�
���S��[�#�j�/��C�
�O�,�,B�3�v�;�-�P�
R����V�0����
�
���!�����
�F�F�H�
�F�F�H��=�,�,�
3��.�.�*�U�2��
3��2���
�
���!�����
�F�F�H�
�F�F�H�sE�)CK�-AJ�1BK�K�-K�
K�
K�K�L�L�*1Lc��[[Q22Q*oUO[U2Q2[O
[OQQ,[O[O[OQ5oUO[O29^tt^2UOUQQ5PPP2UO[OQ5vq4UO[U2[U22UOV12UO2UO2P!)%fhK�9hSO2SO2h9h)	a6Resume writing input after a partial-write TimeoutExpired.

Exercises the _input_offset bookkeeping across the
_communicate_io_posix factoring: a first communicate() must time out
mid-write, and a subsequent communicate() must finish delivering the
remaining bytes so the child receives the full input intact.
�irzSimport sys, time; time.sleep(0.5); sys.stdout.buffer.write(sys.stdin.buffer.read())rGg�������?ri�)r8rrarrrKr_r`rLrkrlr�r�LONG_TIMEOUTr�r))r#r>rRrIrJs&    r�-test_communicate_timeout_resume_partial_write�=ProcessTestCase.test_communicate_timeout_resume_partial_writems���5��:�&��-�
�����Z��+�6����
�^�^�T�@�
A��/�/��?�?��?�?�
$��
	��"�"�:�#<�#<�=�=��
�
�j�$�
�7�>��]�]�7�3G�3G�]�H�N�F����S��[�#�j�/�:����V�0�
�F�F�H�
�F�F�H�>�=��
�F�F�H�
�F�F�H�s+�'E�5E
�	AE�
E	�E	�E�"E?c��QFCDAoQFCD5oQFCD)o-oU%c[OUQ$U%c[OUQ$U%c[OUQ$U%fJa[O[1-U@oUO	2UO
d&UO
UO
O2UOd&UO
UOO2UOeCJUO
UOO2CJ,	CJ8	CJD	P!)FrHrIrJ�FT)
rrLrKrr�rH�
assertTrue�closedrIrJ)r#�
stdin_pipe�stdout_pipe�stderr_pipe�optionsrRs&     r�test_communicate_pipe_fd_leak�-ProcessTestCase.test_communicate_pipe_fd_leak�s���'�J�,��#0�K� �G�!�+5�?�?���(�"�,6�O�O���)�"�,6�O�O���)�"� �"�(�(��D�G�D�A��M�M�O��w�w�*���������7��x�x�+���������8��x�x�+���������8�#$1� -�(rc���[O[OQQ,2oUO	2vq#UOUP2UOUP2P!r[)rrKr_r`r�rar�s&   r�test_communicate_returns�(ProcessTestCase.test_communicate_returns�sP�����c�n�n�d�8�:�
;���=�=�?��������&������&rc��[O2vq[OU2[OU2[O[
OQQ[O*,[O[O[OQ5oUOUOO2UOUOO2UOUOO2Q[O*oUOU2vqVUOVT2P!)rzpimport sys,os;sys.stdout.write(sys.stdin.read(47));sys.stderr.write("x" * %d);sys.stdout.write(sys.stdin.read())rG�a)rr�rPrrKr_r`r�
PIPE_MAX_SIZErLr�rIrJrHr�ra)r#�x�yrR�string_to_writerIrJs&      r�test_communicate_pipe_buf�)ProcessTestCase.test_communicate_pipe_buf�s����w�w�y���
�����
��������c�n�n�d�C�&�3�3�	4�5�$.�?�?�$.�O�O�$.�O�O�
5��	
��������'���������'�������
�
�&���!6�!6�6���=�=��9�������1rc�4�[O[OQQ,[O[O[OQ5oUOUOO2UOUOO2UOUOO2UOOQ2UOQ2vq#UOUQ2UOUQ2P!)rz0import sys,os;sys.stdout.write(sys.stdin.read())rGr
ssplitsbananasplitr)
rrKr_r`rLr�rIrPrJrHr�r�rar�s&   r�test_writes_before_communicate�.ProcessTestCase.test_writes_before_communicate�s������c�n�n�d�C�D�$.�?�?�$.�O�O�$.�O�O�
5��	
��������'���������'�������
�
�&�	���
�
�i� ��=�=��2��������0������%rc��[O[OQQ,[O[O[OQ59^tt^2oUO
O
2UO2vq#UOUO]2PPP2P!)%fhP!9h)rzimport sys; sys.exit(0)rG)
rrKr_r`rLrHrPr�rarr�s&   r�)test_communicate_stdin_closed_before_call�9ProcessTestCase.test_communicate_stdin_closed_before_call�s����
�
�s�~�~�t�8�:�$.�O�O�%/�_�_�%/�_�_�	6�6�:;�
�G�G�M�M�O� �}�}���V����Q�\�\�1�-�6�6�6�6�s�A	B2�2C	�;C	c��[OQQ[*Q*,oQ	FCD�o[OU1-Q[O
Q[O
UP	-@oU9^tt^2UOOQ2UOO2UOUOO2Q2UOOQ2UOO2UOUOO2UOUOO2Q2UOUOO]2Q2UOUOO2Q2PPP2CJ�	P!)%fhCJ�9h)
r�import sys,os;a@buf = sys.stdout.buffer;buf.write(sys.stdin.readline().encode());buf.flush();buf.write(b"line2\n");buf.flush();buf.write(sys.stdin.read().encode());buf.flush();buf.write(b"line4\n");buf.flush();buf.write(b"line5\r\n");buf.flush();buf.write(b"line6\r");buf.flush();buf.write(b"\nline7");buf.flush();buf.write(b"\nline8");rHrIzline1
zline3
zline2
zline4
line5
line6
line7
line8)r�r�)r_r`�	SETBINARYrrKrLrHr��flushrarI�readlinerPr�r2)r#r?�extra_kwargrRs&   r� test_universal_newlines_and_text�0ProcessTestCase.test_universal_newlines_and_text�sC���N�N�D��y�(�
&�
&�'��(:�K�� � ��>�'�:�?�?�*2�J�O�O�*5�t�*=�>�A������
�
�i�(����
�
��� � ����!2�!2�!4�i�@����
�
�i�(����
�
����������/�� � ����!2�!2�!4�!*�,�� � ������q�!1�!*�,�� � �������!D�F���	:����s�2D9F:	�:G
�G
c��[O[OQQ[*Q*,[O
[O
]Q5oUO
UOO2UO
UOO2UO2vq#UOUQ2P!)rrjz�buf = sys.stdout.buffer;buf.write(b"line2\n");buf.flush();buf.write(b"line4\n");buf.flush();buf.write(b"line5\r\n");buf.flush();buf.write(b"line6\r");buf.flush();buf.write(b"\nline7");buf.flush();buf.write(b"\nline8");)rJrIr�z#line2
line4
line5
line6
line7
line8)rrKr_r`rkrLr�rIrPrJr�rar�s&   r�#test_universal_newlines_communicate�3ProcessTestCase.test_universal_newlines_communicates������c�n�n�d�.��:�8�8�
9�%/�O�O�$.�O�O�01�!
3��"	
��������'���������'��=�=�?�������C�	Erc�"�[O[OQQ[*[
OQ2*,[O]Q5oUOQ2vq#UOUO]2P!)rrja
                               s = sys.stdin.readline()
                               assert s == "line1\n", repr(s)
                               s = sys.stdin.read()
                               assert s == "line3\n", repr(s)
                              )rHr��line1
line3
)rrKr_r`rk�textwrap�dedentrLr�rarr�s&   r�)test_universal_newlines_communicate_stdin�9ProcessTestCase.test_universal_newlines_communicate_stdin!sq�����c�n�n�d�.��:�X�_�_�N"�>#�#�$�$.�?�?�01�
3���=�=�)9�:���������q�)rc���[O[[O[OP	Q5oUO	2UOUO]2P!)T)rHrIr�)rrKrrLr�rarrQs& r�.test_universal_newlines_communicate_input_none�>ProcessTestCase.test_universal_newlines_communicate_input_none/sF��

���_�#-�?�?�$.�O�O�04�
6��	
�
�
��������q�)rc�:�[O[OQQ[*[
OQ2*,[O[O[OP	Q5oUOUOO2UOUOO2UOQ2vq#UOUO]2UOQU2UOUQ2P!)rrja�
                               s = sys.stdin.buffer.readline()
                               sys.stdout.buffer.write(s)
                               sys.stdout.buffer.write(b"line2\r")
                               sys.stderr.buffer.write(b"eline2\n")
                               s = sys.stdin.buffer.read()
                               sys.stdout.buffer.write(s)
                               sys.stdout.buffer.write(b"line4\n")
                               sys.stdout.buffer.write(b"line5\r\n")
                               sys.stderr.buffer.write(b"eline6\r")
                               sys.stderr.buffer.write(b"eline7\r\nz")
                              )rHrJrIr�ruzline1
line2
line3
line4
line5
zeline2
eline6
eline7
)rrKr_r`rkrvrwrLr�rIrPrJr�rar�assertStartsWithr�s&   r�7test_universal_newlines_communicate_stdin_stdout_stderr�GProcessTestCase.test_universal_newlines_communicate_stdin_stdout_stderr;s������c�n�n�d�.��:�X�_�_�N"�>#�#�$�$.�?�?�$.�O�O�$.�O�O�04�!
6��"	
��������'���������'��=�=�)9�:���������q�)����>��G�	
���f�&@�Arc	��QFD{oQU*o[OQU,o[OU[O[OUQ5oUOPQ5vqVUO
UQ2J}	P!)�utf-16z@import sys; sys.stdout.buffer.write('1\r\n2\r3\n4'.encode('%s'))r)rHrIr�r�z1
2
3
4)r�z	utf-32-be)r_r`rrKrLr�ra)r#r�r�r?�popenrIrJs&      r�-test_universal_newlines_communicate_encodings�=ProcessTestCase.test_universal_newlines_communicate_encodingsWs|��0�H�L���D��N�N�D�$�/�D��$�$�T�+5�?�?�,6�O�O�.6�8�E�#�.�.�R�.�8�N�F����V�\�2�0rc
�"�QFD�vqQo[OQU,o[OU[O[OQUQ5oUOPQ5vqgUO
UQOU22J�	P!)r�z2import sys; sys.stdout.buffer.write(b'[\x80\x80]')rr�)rHrIr�r�r�z[{}]))r��)r�u��)�surrogateescapeu��)�backslashreplacez\x80\x80)r_r`rrKrLr�ra�format)r#r��expectedr�r?r�rIrJs&       r�test_communicate_errors�'ProcessTestCase.test_communicate_errorsms���!
��F�>�D��N�N�D�$�/�D��$�$�T�+5�?�?�,6�O�O�.5�,2�	4�E�
#�.�.�R�.�8�N�F����V�V�]�]�8�%<�=�%!
rc	��[%fQoLQo[%c�[O[O2vq#UQ6�cX[O[OQU12UO[O[OV#12,o[O2o[U2FD{o[OOU[O2oUO![O"U[O$[O&*22J}	UO-QU*2UO/2[]
2FD'o[O0UO322J)	[]2FD�o[4O6[8O:QQ,[4O<[4O<[4O<Q5o	U	O?Q2]*o
UOAU
Q2J�	SFDo[O0U2J	[BODU2P![[1cCK�h9h[c/oSO([(O*6wcgPo=CJ]Po=hh9hSFDo[O0S2J	[BODS2h9h)iirzz4failed to reach the file descriptor limit (tried %d)rz-import sys;sys.stdout.write(sys.stdin.read())rGslime)#r'�resource�	getrlimit�
RLIMIT_NOFILE�	setrlimitr��OSErrorr�r��mkdtemprrrrr�TESTFN�append�open�O_WRONLY�O_CREAT�errno�EMFILE�skipTest�reverserP�poprrKr_r`rLr�rar�rmtree)r#�max_handles�soft�hard�handles�tmpdirr�tmpfilersrR�data�hs&           r�test_no_leaking�ProcessTestCase.test_no_leaking�s"���y��K��K��8�
�%�/�/��0F�0F�G�
���$�;��&�&�x�'=�'=��d�|�L��O�O�H�$6�$6��8N�8N�%)�L�2����!�!�#��	"��;�'��� �g�g�l�l�6�9�3C�3C�D�G��N�N�2�7�7�7�B�K�K��
�
�4J�#K�L�(��
�
�!�#.�/�0�
�O�O���2�Y���������'���2�Y���$�$�c�n�n�d�'K�&L�,6�?�?�,6�O�O�,6�O�O�=���}�}�W�-�a�0��� � ��w�/�����������M�M�&�!��G�Z�(�
��
�����w�w�%�,�,�.���E����0���������M�M�&�!�sb�,I0�
AI0�<K�A7J�C5K�0J�J�J�	K�K�J<�2J<�3	K�<K�K�8K<c��UO[O,Q
N2Q2UO[O,QN2Q2UO[O,QN2Q2UO[O,Q
N2Q2UO[O,QN2Q2UO[O,QN2Q2UO[O,QN2Q2UO[OQP,2Q	2P!)�a b cz"a b c" d ez	ab\"c \ dz
ab\"c " \\" dza\\\b "de fg" hz
a\\\"b c dz"a\\b c" d ez
"a\\b\ c" d e�abzab "")r�rjrs)�ab"c�\rj)r�z \rj)za\\\bzde fgr�)za\"brrj)za\\b crjrs)za\\b\ crjrs)rar�list2cmdliner"s&r�test_list2cmdline�!ProcessTestCase.test_list2cmdline�s�������0�0�1D�E�&�	(�����0�0�1D�E�&�	(�����0�0�1E�F�+�	-�����0�0�1K�L�-�	/�����0�0�1D�E�(�	*�����0�0�1G�H�)�	+�����0�0�1I�J�+�	-�����0�0�$���<� �	"rc��[O[OQQ,[OQ5oUOUOO2UOUO22[OUOO2Q2UO2UOUO2]2P!)rzimport os; os.read(0, 1)r��A)rrKr_r`rLr�rHrPr�pollrr�rgr)rarQs& r�	test_poll�ProcessTestCase.test_poll�s������c�n�n�d�8�:�#-�?�?�
4��	
������
�
�&����!�&�&�(�#�
��������!�4�(�	�����������1�%rc��[O[2oUOUO	2]2UOUO	2]2P!rw�rrKrrar)rQs& r�	test_wait�ProcessTestCase.test_wait�s>�����_�-���������1�%��������1�%rc�T�[O[OQQ,2oUO	[O
29^tt^2oUO
]Q5PPP2UO	[O
29^tt^2oUO
QQ5PPP2UOQ[WO22UOUO
[OQ5]2P!)%fhK�9h)%fhKz9h)r�import time; time.sleep(0.3)ri�-C��6?z0.0001)
rrKr_r`rkrlr)rqrrr}rar�
SHORT_TIMEOUT)r#rRrs&  r�test_wait_timeout�!ProcessTestCase.test_wait_timeout�s������c�n�n�"�$B�D�
E��
�
�
�z�8�8�
9�
9�Q�
�F�F�1�F��:�
�
�
�z�8�8�
9�
9�Q�
�F�F�6�F�"�:��
�
�h��A�K�K� 0�1��������(=�(=��>��B�:�
9��
9�
9�s$�D�D�D	�
D	�D'	� D'	c��UO[29^tt^2[O[Q2PPP2P!)%fhP!9h)r�)rkr�rrKrr"s&r�test_invalid_bufsize�$ProcessTestCase.test_invalid_bufsize�s4���
�
�y�
)�
)����_�h�7�*�
)�
)�
)�s�A�A	�A	c��[O[P2oUOUO	2]2[O[PQ5oUOUO	2]2P!)N)rVr�rQs& r�test_bufsize_is_none�$ProcessTestCase.test_bufsize_is_none�sR�����_�d�3���������1�%����_�d�;���������1�%rc	��[O[OQQ,[O[O[O
]UQ59^tt^2oUOOU2[OUOO22UOO2o[O29^tt^2UOO2PPP2PUmPPP2UO!WO"]2UO!WU2P![cKTh9h)%fhK`9h)%fhKd9h)rzDimport sys;sys.stdout.write(sys.stdin.readline());sys.stdout.flush())rHrIrJrVr�)rrKr_r`rLr�rHr�rrPrgrIrmr�SuppressCrashReportr�rar)r#�liner�r�rR�	read_lines&&&&  r�_test_bufsize_equal_one�'ProcessTestCase._test_bufsize_equal_one�s
��
�
�
�s�~�~�t�64�5�%/�O�O�%/�_�_�%/�%7�%7�&'�1C�E�E�IJ�
�G�G�M�M�$���H�H�Q�W�W�^�^�%�&����)�)�+�I��,�,�.�.���G�G�M�M�O�/�
�A�G�!E�"	
������q�)�����H�-��	�����/�.��E�E�sU�!BE)�"E	�$E�>E)�	E�E�E	�E�E	�E&
�E&
�!E)�)E9	�2E9	c�2�QoUOVP	Q5P!)zline
�r�)r��r#r�s& r� test_bufsize_equal_one_text_mode�0ProcessTestCase.test_bufsize_equal_one_text_modes�����$�$�T�D�$�Irc���Q[OO2*oUO[Q29^tt^2UOUQP
Q5PPP2P!)%fhP!9h)slinezline bufferingrr�)r�linesepr'�assertWarnsRegex�RuntimeWarningr�r�s& r�"test_bufsize_equal_one_binary_mode�2ProcessTestCase.test_bufsize_equal_one_binary_modesT������*�*�,�,��
�
"�
"�>�3C�
D�
D��(�(��s�u�(�M�E�
D�
D�
D�s�A$�$A5	�-A5	�cpuc
��[Q2FDboUO[29^tt^2[O[
[O[OQ5PPP2Jd	P!)%fhJy9h)rzr�)rrkrrrKrrL)r#rs& r�test_leaking_fds_on_error�)ProcessTestCase.test_leaking_fds_on_errorsT���t��A��"�"�#5�6�6�� � ��(2���(2���9�7�6��6�6�6�s�:A6	�6B
�?B
c��]PHoUO[
OQ[8Q02o[OQU,o[OU[OP	Q5oU9^tt^2UO2]*oPPP2UOWP2UOUO]2P![[1cSO	Q2K�h9h)%fhKh9h)rzneed msvcrt.CrtSetReportModezL
            import msvcrt
            import subprocess

            cmd = a

            for report_type in [msvcrt.CRT_WARN,
                                msvcrt.CRT_ERROR,
                                msvcrt.CRT_ASSERT]:
                msvcrt.CrtSetReportMode(report_type, msvcrt.CRTDBG_MODE_FILE)
                msvcrt.CrtSetReportFile(report_type, msvcrt.CRTDBG_FILE_STDERR)

            try:
                subprocess.Popen(cmd,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
            except OSError:
                pass
        r)rJr�)�msvcrt�CrtSetReportMode�AttributeError�ImportErrorr�rvrwrr_r`rrKrLr�rar)r#r�r�r�r�rJs&     r�test_nonexisting_with_pipes�+ProcessTestCase.test_nonexisting_with_pipes s���	:���#�#����$�#�%�&	�	 �
��&�~�~�t�T�*������'1���37�9���T��%�%�'��*�F�������$�������!�,��;��,�	:��M�M�8�9�	:��4�T�s)�C�6C.�C+�C+�*C+�.C>	�7C>	c	��`�,nU1Qko[OUQ5oUO2UO[29^tt^2[
O[[
O[
O[
OQ5PPP2UO2PoRFDo[OU2J	UdUgP!)%fhKK9h[coSoPo=JLPo=hh9hSO2PoRFD5o[OS2J[coSoPo=J/Po=hh9h	SdSgh9h)c�:�[]2FD=oRO[O22[O
Q2J?	P!)�g����MbP?)r�extendrr�r:�sleep)r�fdss �r�open_fds�<ProcessTestCase.test_double_close_on_error.<locals>.open_fdsLs/����2�Y���
�
�2�7�7�9�%��
�
�5�!�r)�targetrG)�	threading�ThreadrDrkr�rrKrrLrrrP)r#r��t�exc�fdrsr�s&     @r�test_double_close_on_error�*ProcessTestCase.test_double_close_on_errorIs�����	"�
���H�-��	���	�	��"�"�7�+�+�� � ��'1���(2���(2���9�,�
�F�F�H��C�����H�H�R�L�����	��!,�+�����C����
�F�F�H��C�����H�H�R�L�����C����
����	��s~�D
�A	C�D
�:C/�C,	�%C,	�'D
�/	D�9D�:D�D�
E �$D<�:E �<	E�E�E�	E �E�E �E c�>``�[O[OQQ,2nUO	RO
P2,nUU1Qko[OQU2oUO2[%c]oLQoRO[OQ5UO	RO
UQQ5RO2UO	RO
UQQ5UO2UO	QQ	U1Q
U1,R2P!)
z?Issue21291: Popen.wait() needs to be threadsafe for returncode.rzimport time; time.sleep(12)c� :�ROQRO212RO2RO2ROQRO12RO2ROQRO12P!)�thread-start-poll-result�thread-after-kill-and-wait�thread-after-second-wait)r�r�r�r)r)r��resultss��r�kill_proc_timer_thread�DProcessTestCase.test_threadsafe_wait.<locals>.kill_proc_timer_threadmsb����N�N�6��	�	��D�E��I�I�K��I�I�K��N�N�8�$�/�/�J�K��I�I�K��N�N�6����H�Irr1riz*unexpected result in wait from main threadrz&unexpected result in second main wait.r�r�i����)r�N)rrKr_r`rarr��TimerrDr'r)rr�r)r#r�r��expected_errorcoder�r�s&   @@r�test_threadsafe_wait�$ProcessTestCase.test_threadsafe_waitfs����������!>�!@�A��������$�/���	J�
�O�O�C�!7�8��	���	��9�!"��"$��
	
�	�	�'�/�/�	�0�������*<�I�	�	K�	
�	�	��������*<�E�	�	G�	
����
	
���<�7�9K�L�5�7I�J�L�!�	"rc��QOQ2o[O[OQU,2oUOUQ2P!)�;rsHello World!)zimport subprocess, syszJretcode = subprocess.call([sys.executable, '-c', 'print("Hello World!")'])zassert retcode == 0)rrr�r_r`r~)r#r�r�s&  r�test_issue8780�ProcessTestCase.test_issue8780�sD���x�x�#�$��
�(�(�#�.�.�$��)E�F�����f�o�6rc��[O2vq[O2vq4[O2vqV[OQ,VUQ5UO[
OOU22UO[
OOU22UO[
OOU22P![c�[
OS2[
OS2[
OS2[
OS2[
OS2[
OS2CKh9h)�*rG)r��mkstemprrKr�rrP�remover+r�exists)r#�ifhandle�ifname�ofhandle�ofname�efhandle�efnames&      r� test_handles_closed_on_exception�0ProcessTestCase.test_handles_closed_on_exception�s���$�+�+�-���#�+�+�-���#�+�+�-���		����s�e�8��
�	
���������/�0����������/�0����������/�0���	��H�H�X���I�I�f���H�H�X���I�I�f���H�H�X���I�I�f��
	�s�C.�.	F�8BF�Fc��[O[[O[O[OQ5oUO	UO
O2UO	UOO2UO	UOO2UOQQ*2P!)rGr.rJ)
rrKrrLr�rIrPrJrHr�rQs& r�test_communicate_epipe�&ProcessTestCase.test_communicate_epipe�sw�����_�#-�?�?�$.�O�O�$.�O�O�
5��	
��������'���������'�������
�
�&�	�
�
�d�U�l�#rc	��QQQ,P
PQ1,Q	NP
PQ1[OQ2P
]Q1,o[OOO[OQ29^tt^2SFD>vq#qE[OV#Q5oVFmUO[U2U2J@	PPP2P!)%fhP!9h)
�lsz&<Popen: returncode: None args: ['ls']>zP<Popen: returncode: None args: ['ls', '--my-opts', 'aaaaaaaaaaaaaaaaaaaaaaaa...>z
my-tool.pyz4<Popen: returncode: 7 args: <FakePath 'my-tool.py'>>rA�r)rT�{z#<Popen: returncode: 123 args: 'ls'>)�daaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaTrzP<Popen: returncode: 0 args: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...>)rz	--my-optsr)rr
r�r�patch�objectrrKrra�repr)r#�casesr�rr��sxrRs&      r�	test_repr�ProcessTestCase.test_repr�s���D�
a��V�U�D�"J�K�
+�U�D�
_�
a�
�
�
��
-�u�a�
C�
E�	
���]�]�
 �
 �
'�
'�
�(8�(8�:J�
K�
K�(-�$��D��$�$�S�6��#��� � ��a��"�-�).�L�
K�
K�
K�s�,AB<�<C
	�C
	c��[O[[OQ5oUO	UO
O2UO2UOQQ*2P!)r�r.rJ)	rrKrrLr�rHrPr)r�rQs& r�!test_communicate_epipe_only_stdin�1ProcessTestCase.test_communicate_epipe_only_stdin�sH�����_�#-�?�?�
4��������
�
�&�	����	�
�
�d�U�l�#r�SIGUSR1zRequires signal.SIGUSR1r�zRequires os.kill�getppidzRequires os.getppidc	��Qo[O[OU2oUO[O[OU2[OQQ,oQFDNoU[
O-o[
OU1-U@9^tt^2oUO2PPP2JP	P!)%fhJe9h)c��P!r r0)�signum�frames&&r�handler�7ProcessTestCase.test_communicate_eintr.<locals>.handler����rrz7import os, signal;os.kill(os.getppid(), signal.SIGUSR1)r�)	�signalr"r�r_r`rrLrKr�)r#r(�old_handlerr?�stream�kw�processs&      r�test_communicate_eintr�&ProcessTestCase.test_communicate_eintr�s���	��m�m�F�N�N�G�<������
�
�v�~�~�{�C�����8�9��+�F��*�/�/�*�B��!�!�$�-�"�-�-���#�#�%�.�-�+�-�-�-�s�$C	�C
�C
�/proc/%d/fdzLinux specificc	��Q[O2*o[OU2oUO[29^tt^2[[[O[O[OQ5PPP2[OU2oUOV#2P!)%fhK99h)z;Test for the fork() failure fd leak reported in issue16327.r2rG)
r�getpid�listdirrkr;r=rrrLra)r#�fd_directory�fds_before_popen�fds_after_exceptions&   r�!test_failed_child_execute_fd_leak�1ProcessTestCase.test_failed_child_execute_fd_leak�s���%�r�y�y�{�2���:�:�l�3��
�
�
�1�
2�
2�#�#�:�?�?�%�?�?�:�?�?�
D�3�!�j�j��6�����)�?�3�
2�s�>C�C	�	C	z+behavior currently not supported on Windowsc��UO[29^tt^2o[O,QN2PPP2UO	WO
OQ2P!)%fhK89h)�/opt/nonexistent_binary)r<�with�somer?)rkrJrr^rar}�filenamer~s& r�%test_file_not_found_includes_filename�5ProcessTestCase.test_file_not_found_includes_filenamesL��
�
�
�0�
1�
1�Q��O�O�O�P�2�������-�-�/H�I�2�
1�s�A(�(A8	�1A8	c��UO[29^tt^2o[OQQ,QQ5PPP2UO	WO
OQ2P!)%fhK89h)�exit�0z/some/nonexistent/directoryr:)rkrJrrKrar}r?r~s& r� test_file_not_found_with_bad_cwd�0ProcessTestCase.test_file_not_found_with_bad_cwdsT��
�
�
�0�
1�
1�Q����f�c�]�0M�N�2�������-�-�/L�M�2�
1�s�A*�*A:	�3A:	c���UO[O[*[O
2UO[O[*[O
2P!r )rMrrKr8�types�GenericAlias�CompletedProcessrrr"s&r�test_class_getitems�#ProcessTestCase.test_class_getitemssD�����j�.�.�u�5�u�7I�7I�J����j�9�9�#�>��@R�@R�Sr�_winapizneed subprocess._winapic	��[O[2oS9^tt^2[OO[OQ[OOQ5oU9^tt^2oUOP2UOUO]2PUmPPP2UOUO2]2PPP2P!)%fhK:9h)%fhP!9h)�WaitForSingleObject��return_value)
rrKrrrrrM�
WAIT_OBJECT_0r)�assert_called_once_with�_handlerra)r#r�r�	mock_waits&   r�test_wait_negative_timeout�*ProcessTestCase.test_wait_negative_timeouts�������0��
�T��J�J�%�%��"�"�%�'�/�/�=�=�&�?�E���)��	�	�"�
��1�1�$�,�,��B�"&����

���T�Y�Y�[�!�,��T�
����T�T�s0�AC3�95C 	�.(C3� C0
�)C0
�+C3�3D	�<D	c
��[O[OQQ,[O[O[OP	Q59^tt^2oQQQ0oUOU]Q5UO]Q5vqEUOUO]Q	WQ
W0Q5UOUQ2UOQU2PPP2P![OcoPo=K�Po=hh9h[OcoSOQ2Po=K�Po=hh9h)%fhP!9h)
z4GH-141473 regression test; the stdin pipe must closez-uczKimport sys
while c := sys.stdin.read(512):
    sys.stdout.write(c)
print()
)rHrIrJr��spam�beans)r�rjriz_communicate() hung waiting on child process that should have seen its stdin pipe close and exitzSTDERR:
z	
STDOUT:
ra################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################)rrKr_r`rLr�rlrprarr~rq)r#r�r�r�rIrJs&     r�)test_post_timeout_communicate_sends_input�9ProcessTestCase.test_post_timeout_communicate_sends_input(s;��
�
�
�����)��!�o�o�!���!����
�
��
��h�Z�u�-��� � ���!��
}�!%�!1�!1�"�!1�!=���
����O�O�Q�#�F�8�;�v�h�?�
�
A�
�!�!�&�&�1��M�M�'�6�*�=
�
��$�,�,�
���
���,�,�
}��	�	�{�|�|��
}��1
�
�
�sg� D7�"C"�<D�AD7�"D�6D�7D7�<D�D7�D4�D4�D/�*D7�/D4�4D7�7E	�E	r0)�r2r3r4r5rSrXrdrmrtryr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr��skipIfr'rrr"r(r.r6r>rArDrOrUrYr_�base_prefix�prefixr\�	sysconfig�is_python_buildr_rcrkrorvr|r�r�r�r�r�r�r�r�r�r�r��
skipUnlessr��hasattrr�r�r�r�r��get_config_varrr�r�r�r�r�r�rrrrr$r(r+rFrLrVrYrardrgrorrrxr{rr�r�r�r�r�r�r�r�r�r�r�r�r�requires_resourcer�r�r�r�rrrrr r+rr0r�isdirr4r9r@rErKrrVr[r6r7r8s@rrErEys�������!�'�F� �
5�5�4�'�
'�'�(�'�'�%�5�4�!� �+�(�<�.)�+�	M�D�A�9��_�_�Y� D�E�G�F�G�
�_�_�Y� D�E�(�F�(��_�_�Y� D�E�(�F�(�
�*�=�&A�N�
K�
�_�_�Y� D�E�
E�F�
E��_�_�Y� D�E�-�F�-�$C��_�_�S�_�_��
�
�2�2�4�D�4�D��_�_�S�_�_��
�
�2�2�4�
�_�_�Y�.�.�0�:�<�4�<�4�4�*�*�
*�9�
6�	/�=�
:�	3�*�*
>�
4�>�&)�)�(�����A�A�7�5�.�#A�@�B�!�B�!�F����A�A�7�5�.�#A�@�B��B��@	0��������0�2F�G�
>�H�
>��_�_�S�\�\�W�,�:�<�
�_�_�Y�-�-�.@�A�Q�F�2�3��_�_�_�T�2�@�B�2�B�3�<�2�,�_�_�Y�-�-�.@�A�Q�F�9�:��_�_�_�T�2�@�B�
>�B�:�

>�@�6�<�������0�2F�G�
:�H�
:�*�'�/�
/�"�"�8@�&5� ]�~�D9�,'�2�.&� .�%F�NE�2*�
*�B�83�,>�*1"�f"�$	&�&�C�8�&�.�,J�N�
���u�%�
9�&�
9�'-�R�:2"�h	7�1�(	$�.�"$�������3�2�4�
�����V�,�+�-�
�����Y�/�.�0�&�0�-�4�&�&��������}�r�y�y�{�'B�C�)�+�@�+�@� �_�_�Y� M�N�J�O�J�
�_�_�Y� M�N�N�O�N�
T������Y�7�2�4�-�4�-� +� +rrEc�`�\sQsQsnQsQsQsQsQsQs	Qs
Q	sQ
sQs
QsQ
sQsQsQs\O(\Q2Q2sQsQsQsQs\O6\Q2Q2sQsQsUsP!)�RunFuncTestCaseiKc�Z�[OQU,o[OU1-U@!)z4Run Python code in a subprocess using subprocess.runr�r_r`rr)r#r�r@�argvs&&, r�
run_python�RunFuncTestCase.run_pythonLs&������d�+���~�~�d�-�f�-�-rc�
�UOQ2oUOUO]/2UO[O
29^tt^2UO
2PPP2P!)%fhP!9hr�)rlrarrkrr|�check_returncode�r#�cps& r�test_returncode�RunFuncTestCase.test_returncodeQsW��
�_�_�7�
8���������+�
�
�
�z�<�<�
=�
=����!�>�
=�
=�
=�s�A1�1B	�:B	c��UO[O29^tt^2oUOQP	Q5PPP2UO	WO
O]/2P!)%fhK89h)r\r�)rkrr|rlrar}rr~s& r�
test_check�RunFuncTestCase.test_checkXsT��
�
�
�z�<�<�
=�
=���O�O�6�d�O�C�>�������/�/��4�>�
=�s�A-�-A=	�6A=	c�x�[O[P	Q5oUOUO]2P!)Tr��rrrrarrps& r�test_check_zero�RunFuncTestCase.test_check_zero]s&��
�^�^�O�4�
8���������*rc��UO[O29^tt^2UOQQQ5PPP2P!)%fhP!9h)rgr�ri)rkrrlrlr"s&r�test_timeout�RunFuncTestCase.test_timeoutbs;��
�
�
�z�8�8�
9�
9��O�O�.��O�?�:�
9�
9�
9�s�A�A	�A	c��UOQ[OQ5oUOQUO2P!)r�r�r��rlrrLrqrIrps& r�test_capture_stdout�#RunFuncTestCase.test_capture_stdoutjs*��
�_�_�_�Z�_�_�_�
E���
�
�g�r�y�y�)rc��UOQ[OQ5oUOQUO2P!)r�r�r�)rlrrLrqrJrps& r�test_capture_stderr�#RunFuncTestCase.test_capture_stderros1��
�_�_�C�$.�O�O��5���
�
�g�r�y�y�)rc�(�[O2oUOUO2UO	Q2UO]2UO
QU[OQ5oUOQUO2P!)r�r�r�r�)r�r�r�rPr�r�rlrrLrqrI)r#r�rqs&  rr��+RunFuncTestCase.test_check_output_stdin_argtsj��
�
#�
#�
%��������!�
�����
����
�
�_�_�I������2��	
�
�
�g�r�y�y�)rc��UOQQ[OQ5oUOQUO2P!)r�r�)r�rIr�rrps& rr��+RunFuncTestCase.test_check_output_input_args5��
�_�_�H��j�o�o��7��	
�
�
�g�r�y�y�)rc��[O2oUOUO2UO	Q2UO]2UO
[QQ59^tt^2oUOQUQQ5oPPP2UOQWOO]*2UOQUOO]*2P!)%fhKl9h)r�r�rr�r�r�rHr�)r�r�r�rPr�r�rkr�rlrqr}r?r�s&   rr��6RunFuncTestCase.test_check_output_stdin_with_input_arg�s���
�
#�
#�
%��������!�
�����
����
�
�
�
�z�K��M�M�PQ��_�_�%?�+-�W�%�>�F�M�	
�
�
�g�q�{�{�/�/��2�3��
�
�g�q�{�{�/�/��2�3�M�M�s�3C,�,C<	�5C<	c���UO[O29^tt^2oUOQQ[OQ5oPPP2P!)%fhP!9h)r�rh)rjrI)rkrrlrlrL)r#rrqs&  rr��)RunFuncTestCase.test_check_output_timeout�sI��
�
�
�z�8�8�
9�
9�Q����3��
���!�9�B�:�
9�
9�
9�s�#A�A'	�A'	c��[OO2oQUQ$UOQUQ5oUO	UO
]!2P!)r�r�zCimport sys, os;sys.exit(33 if os.getenv("FRUIT")=="banana" else 31)r�)rr�r�rlrar)r#r�rqs&  r�test_run_kwargs�RunFuncTestCase.test_run_kwargs�sM�������"��"��w��
�_�_�M�!'��)��	
�������+rc���[%cQLQo[OU2oUeUOUQ02[	U2o[
OU[
OQ5oUOUO]2UO[29^tt^2[
OU[
OP	Q5PPP2P!)%fhP!9h)ztree.comrz required for this testr�)rIr)r'rrr�r
rrr�rarrkr�)r#�progr�ress&   r�test_run_with_pathlike_path�+RunFuncTestCase.test_run_with_pathlike_path�s���'�Y�z�D���|�|�D�!���<��M�M�T�F�"9�:�;���~���n�n�T�*�*<�*<�=���������+�
�
�
�y�
)�
)��N�N�4�
�(:�(:�$�G�*�
)�
)�
)�s�*(C�C-	�%C-	c��[O[O2oUQQ,o[O
U2oUO
UO]92P!)rsimport sys; sys.exit(57))rrr_r`rrrar�r#rr?r�s&   r�&test_run_with_bytes_path_and_arguments�6RunFuncTestCase.test_run_with_bytes_path_and_arguments�sC���{�{�3�>�>�*���d�7�8���n�n�T�"���������,rc��[[O2oUQQ,o[OU2oUOUO]92P!)rzimport sys; sys.exit(57))r
r_r`rrrarr�s&   r�)test_run_with_pathlike_path_and_arguments�9RunFuncTestCase.test_run_with_pathlike_path_and_arguments�s?������'���d�6�7���n�n�T�"���������,rz#Maybe test trigger a leak on Ubuntuc�^�[OQQ,o[OU-Q5P!)rr
r�rj)r#r?s& r�test_run_with_an_empty_env�*RunFuncTestCase.test_run_with_an_empty_env�s$������f�-��	���t��$rc��UOQP	Q5oUOQUO2UOQUO2P!)z>import sys;sys.stdout.write('BDFL'); sys.stderr.write('FLUFL')��capture_outputr�sFLUFL)rlrqrIrJrps& r�test_capture_output�#RunFuncTestCase.test_capture_output�sE��
�_�_�:�-1��2��	
�
�
�g�r�y�y�)��
�
�h��	�	�*rc���UO[QQ59^tt^2UOQ[OQ5PPP2P!)%fhP!9h)z"STDOUT can only be used for stderrrr�r�)rkr�rlrr�r"s&r�test_stdout_stdout�"RunFuncTestCase.test_stdout_stdout�sQ��
�
�
�z�9��<�<��O�O�6�#-�#4�#4�
�
6�<�<�<�<�s�"A
�
A	�A	c��[O2oUOUO2UO	[
QQ59^tt^2oUO
QP	UQ5oPPP2UOQWOO]*2UOQUOO]*2P!)%fhKl9h)zAExpected ValueError when stdout and capture_output args supplied.rr�)r�rIrIr��
r�r�r�rPrkr�rlrqr}r?r�s&   r�#test_stdout_with_capture_output_arg�3RunFuncTestCase.test_stdout_with_capture_output_arg����
�
#�
#�
%��������!�
�
�
�z�"��$�$�'(��_�_�%?�59�"�%�F�F�$�
	
�
�
�h���� 0� 0�� 3�4��
�
�&����(8�(8��(;�<�
$�$���C
�
C	�C	c��[O2oUOUO2UO	[
QQ59^tt^2oUO
QP	UQ5oPPP2UOQWOO]*2UOQUOO]*2P!)%fhKl9h)zAExpected ValueError when stderr and capture_output args supplied.rr�)r�rJrJr�r�r�s&   r�#test_stderr_with_capture_output_arg�3RunFuncTestCase.test_stderr_with_capture_output_arg�r�r�z)requires posix like 'sleep' shell commandc�`�[O2o[OQP	QP	Q5UO	Q2UOWU*
QQWQ0Q5P![O
c5o[O2o[O2oPo=KePo=hh9h)	zJOutput capturing after a timeout mustn't hang forever on open filehandles.zsleep 3rh)rrjr�zTimeoutExpired not raised.g�?z/TimeoutExpired was delayed! Bad traceback:
```
z```r)	r:r;rrrprl�	traceback�
format_excr<)r#�before_secsr��
after_secs�stackss&    r�.test_run_with_shell_timeout_and_capture_output�>RunFuncTestCase.test_run_with_shell_timeout_and_capture_output�s����n�n�&��	4��N�N�9�D�#�*.�
0�
�I�I�2�3����
�[�0�#�O�!�(�#�'�	�	(���(�(�	,����)�J��)�)�+�F��	,�s�A$�$B-�8B-�9*B(�(B-c�X�[OQ2o[O[O
QQU,P	Q5oUOO2oUO[U2]U2UOU]*Q2UOU]*Q2P!)z�            from subprocess import *
            run("echo hello", shell=True, text=True)
            check_output("echo hello", shell=True, text=True)
            z-Xwarn_default_encodingrr�s<string>:2: EncodingWarning: s<string>:3: EncodingWarning: )rvrwrrr_r`rJ�
splitlinesrarr~)r#r�rq�liness&   r�test_encoding_warning�%RunFuncTestCase.test_encoding_warnings������ ���
�^�^�S�^�^�-F��d�S�+/�1���	�	�$�$�&������U��Q��.����e�A�h�(H�I����e�A�h�(H�Irr0) r2r3r4r5rlrrruryr|r�r�r�r�r�r�r�r�r�r�r�rbr'r�r�r�r�r�r]r�r�r6r7r8s@rrhrhKs�����.�
"�5�
+�
@�*�
*�
	*�*�4�9�,�H�-�-�����$I�J�%�K�%�+�6�
=�
=� �_�_�Y� K�L�
(�M�
(�J�Jrrhc��QFD+o[%fJ[OU2Ut!	[OQ2g[cJSh9h)�staffz?No identified group name to use for this test on this platform.)r��nogroup�grp�nobody�	nfsnobody)r��getgrnam�KeyErrorr�r�)�
name_groups r�_get_test_grp_namer�sS��H�
��3�
����Z�(���
I���� a�b�b��	�
��
�s�A
�
	A�A�AzPOSIX specific testsc�``�\sQsQsnU1QksQsQsQsQsQQ\	O2s\OQ	2Q
2s\OQ	2Q2s\O"\O&O)Q2%(Q
2Q2sQs\O.\\Q29%c
\\Q2Q2Q2s\O.\\Q2Q2Q2s\O"\\Q2Q2Q2s\O.\\Q2Q2Q2s\O"\\Q2Q2Q2s\O.\\Q2Q2Q 2s\O.\\Q2Q2Q!2sQ"s Q#s!\O"\"9%f\\Q$2%(Q%2Q&2s#Q's$Q(s%Q)s&Q*s'Q+s(Q,s)Q-Q.\	O2s*\O"\O&O)Q/2%(Q02Q12s+Q2s,\O"\-O\Q36HQ42Q52s/Q6s0Q7s1Q8s2Q9s3Q:s4Q;s5Q<s6\O"\-O\OoQ~2Q=2Q>2s8Q?s9Q@s:QAs;QBs<QCs=QDs>QEs?QFs@QGsAQHsBQIsCQJsDQKsEQLsFQMsGQNsHQOsIQPsJQQsKQRsLQSsMQTsNQUsOQVsPQWsQQXsRQYsSQZsT\O"\-O\OoQ[29%c:\O�Q\2O�\O�Q]2O�6HQ^2Q_2sW\XO�]
]2Q`2sZQas[Qbs\Qcs]Qds^Qes_Qfs`QgsaQhsbQiscQjsd\XO�Qk2sf\XO�Ql2sgQmshQnsiQosjQpsk\O.\lPI9%c
\\lQq2Qr2Qs2smQtsnQusoQvspQwsq\O"\rO�Qx2%(Qy2\tO�2\OQzP
Q{5Q|222svQ}swUsxU9sy!)�POSIXProcessTestCaseic�4:�[RU_2QUmP!)z/_this/pa.th/does/not/exist)�superr$�_nonexistent_dir�r#�	__class__s&�rr$�POSIXProcessTestCase.setUps���
��
�� =��rc���[OUO2UOQUO*2W![coSoPo=S!Po=hh9h)z,chdir to nonexistent directory %s succeeded.)r�chdirr�rpr�)r#rs�desired_exceptions&  r�_get_chdir_exception�)POSIXProcessTestCase._get_chdir_exception!s`��		-��H�H�T�*�*�+�
�I�I�D��+�+�,�
-� � ���	"�!"��!� ��	"�s� A�	A�A�A�Ac���UO2o[O[OQP,UO
Q5oUO
QU*2P![c~oSOSOSO2SOSOSO2SOSOSO2Po=P!Po=hh9h)z;Test error in the child raised in the parent for a bad cwd.rr:�Expected OSError: %s�r�rrKr_r`r�rpr�rar��strerrorr?�r#r�rRrss&   r�test_exception_cwd�'POSIXProcessTestCase.test_exception_cwd.s��� �5�5�7��
	B�� � �#�.�.�$��!;�%)�%:�%:�<�A�
�I�I�,�/@�@�A���	E�
���.�4�4�a�g�g�>����.�7�7����D����.�7�7����D�D��	E���3A � 	C(�*C(�+A2C#�#C(c���UO2o[O[OQP,UO
Q5oUO
QU*2P![c~oSOSOSO2SOSOSO2SOSOSO2Po=P!Po=hh9h)zBTest error in the child raised in the parent for a bad executable.rrr�r�r�s&   r�test_exception_bad_executable�2POSIXProcessTestCase.test_exception_bad_executable=s��� �5�5�7��
	B�� � �#�.�.�$��!;�,0�,A�,A�C�A�
�I�I�,�/@�@�A���	E�
���.�4�4�a�g�g�>����.�7�7����D����.�7�7����D�D��	E�r�c��UO2o[OUOQP,2oUO	QU*2P![
c~oSO
SOSO2SO
SOSO2SO
SOSO2Po=P!Po=hh9h)z?Test error in the child raised in the parent for a bad args[0].rr�)
r�rrKr�rpr�rar�r�r?r�s&   r�test_exception_bad_args_0�.POSIXProcessTestCase.test_exception_bad_args_0Ls��� �5�5�7��		B�� � �$�"7�"7��r�!B�C�A�
�I�I�,�/@�@�A���	E�
���.�4�4�a�g�g�>����.�7�7����D����.�7�7����D�D��	E�s�#A�	C�C�A2C�Cc�(`�\sQsQsnQsQsUsP!)�&POSIXProcessTestCase.PopenNoDestructoriac��P!r r0r"s&r�__del__�.POSIXProcessTestCase.PopenNoDestructor.__del__br*rr0)r2r3r4r5r�r6r7r8s@r�PopenNoDestructorr�as����	�	rr�zsubprocess._fork_execc	�2�QoV!m[OQ[Q59^tt^2UO	[
29^tt^2UO
Q,2PPP2PPP2P!)%fhK9h)%fhP!9h)z>Test error passing done through errpipe_write in the good casec��U]
*oQO[O2O2o[O
UQU*Q*2]!)�
z{:x}sOSError:�:)r�r��EISDIRr'rr�)r?�
errpipe_write�err_codes*  r�proper_error�HPOSIXProcessTestCase.test_exception_errpipe_normal.<locals>.proper_errorhsA�� ��H�M��}�}�U�\�\�2�9�9�;�H��H�H�]�K�(�$:�T�$A�B�r�subprocess.os.waitpid��side_effect�non_existent_command)r�rr�ChildProcessErrorrk�IsADirectoryErrorr�)r#�	fork_execr�s&& r�test_exception_errpipe_normal�2POSIXProcessTestCase.test_exception_errpipe_normalesp��	�!-��
�Z�Z�/�$5�7�7��"�"�#4�5�5��&�&�(>�'?�@�6�7�7�5�5��7�7�7�s/�B�
A2	� B�2B
�;B
�=B�B	�B	c	�`�QnU1QkoV!m[OQ[Q59^tt^2UO	[
O29^tt^2oUOQ,2PPP2PPP2UO[R2[WO22P!)%fhKH9h)%fhKS9h)zRTest error passing done through errpipe_write where its not
in the expected formats�ޭc�J:�U]
*o[OUR2]!)r�)rr�)r?r��
error_datas* �r�	bad_error�GPOSIXProcessTestCase.test_exception_errpipe_bad_data.<locals>.bad_error{s��� ��H�M�
�H�H�]�J�/�rr�r�r�)r�rrr�rkr�SubprocessErrorr�rqrrrr})r#r�r�rsr�s&&  @r�test_exception_errpipe_bad_data�4POSIXProcessTestCase.test_exception_errpipe_bad_datavs����)�
�	�!*��
�Z�Z�/�$5�7�7��"�"�:�#=�#=�>�>�!��&�&�(>�'?�@�?�7�
	
�
�
�d�:�&��A�K�K�(8�9�?�>��7�7�s/�(C�B0	�0C�0C
�9C
�;C�C	�C	�/proc/self/statuszneed /proc/self/statusc��[OQQ,P
Q5oUO2FDoUOQ2%fJSoL	UO	Q2[OQQ,P	Q5oUO2FDoUOQ2%fJSoL	UOWWQQ5P!)�catr)�restore_signalssSigIgnz&SigIgn not found in /proc/self/status.z=restore_signals=True should've unblocked SIGPIPE and friends.r)rr�r�r�r��assertNotEqual)r#�default_proc_statusr��default_sig_ign_mask�restored_proc_status�restored_sig_ign_masks&     r�test_restore_signals�)POSIXProcessTestCase.test_restore_signals�s���)�5�5��+�,� %�'��(�2�2�4�D����y�)�)�'+�$��5�

�M�M�B�C�)�6�6��+�,� $� &��)�3�3�5�D����y�)�)�(,�%��6�	
���0�2G�!3�	�	4rc�2�[O[OQQ,P	Q5o[O
]2o[
U2oUOV#2P![c,oSO[O6wcgPo=P!Po=hh9h)rzimport os; print(os.getsid(0)))�start_new_session)rr�r_r`r�getsid�intr�PermissionErrorr��EPERM)r#r��
parent_sid�	child_sidrss&    r�test_start_new_session�+POSIXProcessTestCase.test_start_new_session�sy��
	7��,�,��^�^�T�+K�L�&*�,�F����1��J��F��I����
�6��
�	��w�w�%�+�+�%��&��	��#�)A � 	B�*B�+B�
B�B�setpgid�getpgidz!no setpgid or getpgid on platformc�2�[O[OQQ,]Q5o[O
]2o[
U2oUOV#2P![c,oSO[O6wcgPo=P!Po=hh9h)rzimport os; print(os.getpgid(0)))�
process_group)rr�r_r`rrrrrr�r)r#r��parent_pgid�
child_pgidrss&    r�test_process_group_0�)POSIXProcessTestCase.test_process_group_0�sy��
	9��,�,��^�^�T�+L�M�"#�%�F��*�*�Q�-�K��V��J�����8��
�	��w�w�%�+�+�%��&��	�r�setreuidzno setreuid on platformc��[O2oUQ6wcQLQU,o[OQ6wcQLQo[d)[O
U2UO
U2SFD�oQ
FD�oUOVEQ59^tt^2[O[OQQ,UUQ5o[U[2%c"[O
U2OoLSo[U2oUO!V�2PPP2J�	J�	UO-[.29^tt^2[O0[2PQ5PPP2UO-[429^tt^2[O0[2[O6[O8QQ	5PPP2[eKUdEUO-[.29^tt^2[O0[2UQ5PPP2P!P!P![cPoCK�h9h["cvo	S	O$[$O&6Xc1SO!S	O([O2Po	=	CKtSO+S	O(2Po	=	CK�Po	=	hh9h)%fhCJM9h)%fhCKq9h)%fhCK%9h)%fhP!9h)���darwinr��unknown)�user�	close_fdsrzimport os; print(os.getuid())�r&)r'r�r&rO�)r�geteuidr_r��pwd�getpwnamr�r��subTestrr�r`�
isinstancerr�pw_uidrrarr��EACCESr?rrkr�rxr�
OverflowErrorrHr�)
r#�uid�
test_users�name_uidr&r'r��user_uid�
child_userrss
&         r�	test_user�POSIXProcessTestCase.test_user�s(���j�j�l��"�e�|�e���<�
�"�|�|�x�7�8�Y���?�
 ����X�&��!�!�(�+�
�D�*�	��\�\�t�\�A�A�?�!+�!8�!8�!$����!@�!B�%)�*3�	"5��&�d�C�0�0�'*�|�|�D�'9�'@�'@�H�'+�H�%(��[�
��(�(��>�%B�A�+��.�
�
�z�
*�
*��!�!�/��;�+��
�
�}�
-�
-��!�!�/�&(�i�i�R�Z�Z�e�
M�.��;�8�/��"�"�:�.�.��%�%�o�H�E�/�.�0�;��E�
 ���
 ��+�:��7�7�e�l�l�2� �,�,�Q�Z�Z����H�H� �-�-�a�j�j�9�9��	:��B�A�A��(+�
*�
*��.�
-�
-��
/�.�.�s��'H�J1
�*H.�?J1
�?J1
�K�;K�/K.�	H+�$H+�*H+�.	J.�8J.�9J)�*J)�J1
�J)�#J1
�)J.�.J1
�1K�:K�K	�K	�K+	�#K+	�.K?	�7K?	z setreuid() available on platformc��UO[29^tt^2[O[QQ5PPP2P!)%fhP!9h)�r(�rkr�rrxrr"s&r�test_user_error�$POSIXProcessTestCase.test_user_error�s2��
�
�
�z�
*�
*��!�!�/��>�+�
*�
*�
*���A�A	�A	�setregidzno setregid() on platformc���[O2oUQ6wcQLQ,o[2o[dUO	U2V!,*FD�oQFD�oUOVEQ59^tt^2[O[OQQ,UUQ5o[U[2%c"[OU2OoLSo[U2oUOV�2PPP2J�	J�	UO'[(29^tt^2[O*[,PQ5PPP2UO'[.29^tt^2[O*[,[O0[O2QQ5PPP2[eEUO'[(29^tt^2[O*[,UQ5PPP2P!P![ c'o	SO#S	O$2Po	=	CK,Po	=	hh9h)%fhCJ�9h)%fhCK9h)%fhK�9h)%fhP!9h)	r"r#)�groupr'rzimport os; print(os.getgid())�rA)r'r�rArOr))r�getegidr�r�r�r-rr�r_r`r.rrr��gr_gidrrarrr?rkr�rxrr1rHr�)
r#�gid�
group_listr�rAr'r��	group_gid�child_grouprss
&         r�
test_group�POSIXProcessTestCase.test_group�s����j�j�l��"�e�|�e��7�
�'�)�
��?����j�)��%�'�'�E�*�	��\�\��\�C�C�A�!+�!8�!8�!$����!@�!B�&+�*3�	"5��&�e�S�1�1�(+���U�(;�(B�(B�I�(-�I�&)�&�k���(�(��@�!D�C�+�(�,�
�
�z�
*�
*��!�!�/��<�+��
�
�}�
-�
-��!�!�/�&(�i�i�R�Z�Z�u�
N�.��;��"�"�:�.�.��%�%�o�Z�H�/�.���'+�6��)�)�!�*�*�5�5��6��D�C�C��&+�
*�
*��.�
-��
/�.�.�s~�3H(
�5*G4�H(
�5?H(
�!H=�#;I�I$�4	H%�>H%�?H �H(
� H%�%H(
�(H:�1H:�=I	�I	�I!	�I!	�$I5	�-I5	z setregid() available on platformc��UO[29^tt^2[O[QQ5PPP2P!)%fhP!9h)r:rBr;r"s&r�test_group_error�%POSIXProcessTestCase.test_group_error)	s2��
�
�
�z�
*�
*��!�!�/��?�+�
*�
*�
*�r>�	setgroupszno setgroups() on platformc�n�[O2oUQ6wcQLQ,oUOVQ5P!)r"r#�rErF)rrC�_test_extra_groups_impl)r#rErFs&  r�test_extra_groups�&POSIXProcessTestCase.test_extra_groups.	s.���j�j�l��"�e�|�e��7�
��$�$��$�Drc�T�UO[O2,Q5P!)rP)rQrrCr"s&r�test_extra_groups_empty_list�1POSIXProcessTestCase.test_extra_groups_empty_list4	s���$�$�����"�$�Erc�:�[2o[dUOU2[O[
OQQ,UQ5o[O2o[OU2o[dJSTt,tFD;o[U[2%c![OU2OLSMJ=	ooLSoUO[!U2[!U22[eFUO+[,29^tt^2[O.[0U,Q5PPP2P!P!ttoh["c7o	SO%S	O&2SO)Q2Po	=	K�Po	=	hh9h)%fhP!9h)Nrz;import os, sys, json; json.dump(os.getgroups(), sys.stdout)��extra_groupsz-setgroup() EPERM; this test may require root.)r�r�r�rr�r_r`r�	getgroups�json�loadsr.rrr�rDra�setrrr?r�rkr�rxr)
r#rErFr�r��
parent_groups�child_groups�g�desired_gidsrss
&$$       rrQ�,POSIXProcessTestCase._test_extra_groups_impl8	sL��'�)�
��?����j�)�	C��,�,��^�^�T�R�T�!+�-�F��L�L�N�M��:�:�f�-�L���)3� 5�)3�A�;E�Q��:L�:L����Q�� 6� 6�RS� S�)3�� 5�� *�����S��.��L�0A�B��;��"�"�:�.�.��%�%�o�4>�<�A�/�.��� 5���	K����a�j�j�)��M�M�I�J�J��	K�� /�.�.�s;�)E�E�"&E�F	�	F�F�,F�F�	F	�F	c	��UO[29^tt^2[O[P,Q5PPP2UO[29^tt^2[O[[
O[
OQ,Q5PPP2P!)%fhKs9h)%fhP!9h)r�rX)r'r�rYr))rkr�rrxrrrHr�r"s&r�&test_extra_groups_invalid_gid_t_values�;POSIXProcessTestCase.test_extra_groups_invalid_gid_t_valuesX	s|��
�
�
�z�
*�
*��!�!�/���E�+��
�
�z�
*�
*��!�!�/�&(�i�i�R�Z�Z�05�w�
8�+�
*�+�
*��+�
*�
*�s#�B(�"<B;�(B8	�1B8	�;C	�C	�umaskzPOSIX umask() is not available.c	���Po[O2o[OO	UQ2o[
O[OQQU8Q0,]+Q5[OU2OQ*oQoUOVC[U2Q[U20Q	5Ud[OU2P!P!Sd[OS2hh9h)
NrZrzopen(z, 'w').close())rf��z != r)r�r�rrrrrxr_r`�stat�st_modera�octrr�)r#r��namerk�
expected_modes&    r�
test_umask�POSIXProcessTestCase.test_umaska	s�����	&��%�%�'�F��7�7�<�<���0�D�
�!�!��^�^�T�U�4�(�.�+I�J��
!�
�g�g�d�m�+�+�e�3�G�!�M����]�$'�
�$6�#7�t�C��L�>�!J�
�
L��!��
�
�f�%�"��v�!��
�
�f�%�"�s�B6C�C6�C6c�>�[O29^tt^2[O[O
QQ,2oUO
2PPP2UOWO'[O2P!)%fhK=9h)rzimport os; os.abort())rr�rrKr_r`r)rarr+�SIGABRTrQs& r�test_run_abort�#POSIXProcessTestCase.test_run_abortw	sd��
�
(�
(�
*�
*�� � �#�.�.�$�"9�";�<�A�
�F�F�H�+�	
���!�,�,�����7�	+�
*�s�8B�B	�B	c�2�[O[[O2'Q2o[U2oUO
QUO22UO
QU2UO
[[O2U2P!)�fake cmdr+�SIG)rr|rr+rrrrrq�lower�r#r��error_strings&  r�"test_CalledProcessError_str_signal�7POSIXProcessTestCase.test_CalledProcessError_str_signal	si���+�+�S����-@�,@�*�M���3�x��	
�
�
�h�� 2� 2� 4�5�	
�
�
�e�\�*��
�
�c�&�.�.�)�<�8rc�p�[OQQ2o[U2oUOQU2P!)i?��rvzunknown signal 9876543.i�Ki��rr|rrrqrys&  r�*test_CalledProcessError_str_unknown_signal�?POSIXProcessTestCase.test_CalledProcessError_str_unknown_signal�	s,���+�+�H�j�A���3�x���
�
�/��>rc�p�[O]Q2o[U2oUOQU2P!)r�rvznon-zero exit status 2.r~rys&  r�$test_CalledProcessError_str_non_zero�9POSIXProcessTestCase.test_CalledProcessError_str_non_zero�	s,���+�+�A�z�:���3�x���
�
�/��>rc��[O[OQQ,[OQQ5oU9^tt^2UOUOO2Q2PPP2P!)%fhP!9h)rr�c�2�[OQQ2!)r��apple)r�putenvr0rr�<lambda>�3POSIXProcessTestCase.test_preexec.<locals>.<lambda>�	s���	�	�'�7�0Kr)rI�
preexec_fn�applerurQs& r�test_preexec�!POSIXProcessTestCase.test_preexec�	sb��
���c�n�n�d�E�F�%/�O�O�(K�	
M��
�Q����Q�X�X�]�]�_�h�7��Q�Q�Q�s�+A:�:B	�B	c�x�Qo[O[OQP,UQ5oUO	Q2P![O
c,oSO
[OQ2Po=P!Po=h[c/oSOQSO]*2Po=P!Po=hh9h)c��[Q2g)z'What if two swallows carried a coconut?�r�r0rr�raise_it�=POSIXProcessTestCase.test_preexec_exception.<locals>.raise_it�	s���F�G�Grr�r�zEException raised by preexec_fn did not make it to the parent process.z)Expected a ValueError from the preexec_fn�coconut)rrKr_r`rpr�rP�
_fork_execr�rqr?)r#r�rRrss&   r�test_preexec_exception�+POSIXProcessTestCase.test_preexec_exception�	s���	H�	0�� � �#�.�.�$��!;�,4�6�A�
�I�I�/�
0���)�)�	A��O�O��)�)�?�
A�
A���	0��M�M�)�Q�V�V�A�Y�/�/��	0�s/�)A�B9�B9� A=�=B9�
B9�#B4�4B9c�2`�\sQsQsnQsQsQsQsUsP!)�+POSIXProcessTestCase._TestExecuteChildPopeni�	z3Used to test behavior at the end of _execute_child.c�^�Vm[OOU,UN3-U@P!r )�	_testcaserrKr�)r#�testcaser?r@s&&*,rr��4POSIXProcessTestCase._TestExecuteChildPopen.__init__�	s%��%�N����%�%�d�<�T�<�V�<rc�L�[OOU,UN3-U@[]2Tt,tFD(o[O
Q[O2MJ*	ooSFDkoUOOVPOO2UOO2UOO21QQ5Jm	SFDo[OU2J	P!ttohSFDo[OS2J	h9h[]2Tt,tFD(o[O
Q[O2MJ*	LttohooSFDkoSOOXPOO2SOO2SOO21QQ5Jm	SFDo[OS2J	hSFDo[OS2J	h9h9h)��	/dev/zeroz!At least one fd was closed early.r)rrKrArrr��O_RDONLYr�r�rHrgrIrJrP)r#r?r@r��devzero_fdsr�s&*,   rrA�:POSIXProcessTestCase._TestExecuteChildPopen._execute_child�	s���
%�� � �/�/��F�t�F�v�F�).�a��2�(0�1� "�w�w�{�B�K�K�@�(0��2�%�)�����2�2� "�Z�Z�%6�%6�%8�$�+�+�:L�:L�:N�%)�[�[�%7�%7�%9�%;�$G�3�I�*�*�������*��2��*�������*��).�a��2�(0�1� "�w�w�{�B�K�K�@�(0��2��2�%�)�����2�2� "�Z�Z�%6�%6�%8�$�+�+�:L�:L�:N�%)�[�[�%7�%7�%9�%;�$G�3�I�*�*�������*��k�������*�sB�%D%�0C;�'A2D�"D"�%
H#�20E#�"H#�+A2G>�!H#�>"H � H#)r�)	r2r3r4r5rCr�rAr6r7r8s@r�_TestExecuteChildPopenr��	s����A�	=�	%�	%rr�r�z/dev/zero required.c� �QoUO[O29^tt^2UOU[[O
[O
[O
UQ5PPP2P!)%fhP!9h)z6Issue16140: Don't double close pipes on preexec error.c�0�[OQ2g)z-force the _execute_child() errpipe_data path.)rr�r0rrr��WPOSIXProcessTestCase.test_preexec_errpipe_does_not_double_close_pipes.<locals>.raise_it�	s���,�,�C�E�
Er)rHrIrJr�)rkrr�r�rrL)r#r�s& r�0test_preexec_errpipe_does_not_double_close_pipes�EPOSIXProcessTestCase.test_preexec_errpipe_does_not_double_close_pipes�	s_��	E��
�
�z�9�9�
:�
:��'�'��o�(�o�o�j�o�o�)���8�
(�
E�;�
:�
:�
:�s�AA<�<B
	�B
	c���[O2o[O2UO[O22[O
[OQP,QQ5UO[O2Q2[O2UO[O22[O
[OQP,QQ5UO[O2Q2U%f[O2P!P!S%f[O2hh9h)rc��P!r r0r0rrr��EPOSIXProcessTestCase.test_preexec_gc_module_failure.<locals>.<lambda>�	���trr�z#Popen enabled gc when it shouldn't.c��P!r r0r0rrr�r��	r�rzPopen left gc disabled.)
�gc�	isenabled�disabler+rr^r_r`�enablerP)r#�enableds& r�test_preexec_gc_module_failure�3POSIXProcessTestCase.test_preexec_gc_module_failure�	s����,�,�.��	��J�J�L����R�\�\�^�,��O�O�S�^�^�T�2�6�'3�
5����R�\�\�^�B�
D�
�I�I�K��O�O�B�L�L�N�+��O�O�S�^�^�T�2�6�'3�
5��O�O�B�L�L�N�,E�F���
�
����7��
�
���s�DE	�	E)�E)r$z!setrlimit() seems to fail on OS Xc�^�]QHGoGoGoWW2oUvqgWU]U12UO
V#U2[O[OQP,QQ5UOQ2P![coSOS2Po=K�Po=hh9h[cP!h9h)r)r�r��RLIMIT_NPROCrc��P!r r0r0rrr��@POSIXProcessTestCase.test_preexec_fork_failure.<locals>.<lambda>�	r�rr�z.RLIMIT_NPROC had no effect; probably superuser)r�r�r�r�r�r�r�rr^r_r`�BlockingIOError)r#r�r�r�r��limitsr�r�s&       r�test_preexec_fork_failure�.POSIXProcessTestCase.test_preexec_fork_failure�	s���
	�C�C��<�(���	���,��D�	�*����	��8�	L��O�O�S�^�^�T�2�6�'3�
5�
�M�M�J�K���	��M�M�#����	���	��	�s4�
A4�*B�4	B�>B�?B�B�	B,�'B,�+B,c��[O2vq[UQQQ59^tt^2oUOQ[O
*2UOQ[O*2PPP2[OUQ2[OU2oUO2[OU2UOUO]/2P!)%fhK�9h��wr�)r�z#!%s
z(exec '%s' -c 'import sys; sys.exit(47)'
�)r�rr�r�r�
unix_shellr_r`r�chmodrrKr)rrar)r#r��fname�fobjrRs&    r�test_args_string�%POSIXProcessTestCase.test_args_string
s����$�$�&�	��
�"�c�"3�
4�
4���J�J�x�'�"4�"4�4�5��J�J�B��~�~�&�
'�5�	���������U�#��	����
�	�	�%��������r�*�5�
4�s�A
C5�5D	�>D	c���UO[[O[O
QQ,]/Q5UO[[O[O
QQ,]/Q5P!)rr\��startupinfo��
creationflags�rkr�rr^r_r`r"s&rr��&POSIXProcessTestCase.test_invalid_args
sb�����*�j�o�o��>�>�4�5�7�&(�	�	*�	
���*�j�o�o��>�>�4�5�7�(*�	�	,rc�`�[OO2oQUQ$[OQ,][O
UQ5oU9^tt^2UO
UOO2OQ2Q2PPP2P!)%fhP!9h�r�r�zecho $FRUIT�rrIr�s 	
r��
rr�r�rrKrLrarIr2r��r#r�rRs&  r�test_shell_sequence�(POSIXProcessTestCase.test_shell_sequence
ss�������"��!��w�����m�_�A�$.�O�O�!'�
)���Q����Q�X�X�]�]�_�2�2�<�@�(�K��Q�Q�Q�s�:B�B-	�%B-	c�^�[OO2oQUQ$[OQ][O
UQ5oU9^tt^2UO
UOO2OQ2Q2PPP2P!)%fhP!9hr�r�r�s&  r�test_shell_string�&POSIXProcessTestCase.test_shell_string$
sq�������"��!��w�����]�!�$.�O�O�!'�
)���Q����Q�X�X�]�]�_�2�2�<�@�(�K��Q�Q�Q�s�:B�B,	�$B,	c���[O2vq[UQQQ59^tt^2oUOQ[O
*2UOQ[O*2PPP2[OUQ2[OU2o[OU2UOU]/2P!)%fhKg9hr�)r�rr�r�rr�r_r`rr�rr^rra)r#r�r�r�rcs&    r�test_call_string�%POSIXProcessTestCase.test_call_string.
s����$�$�&�	��
�"�c�"3�
4�
4���J�J�x�'�"4�"4�4�5��J�J�B��~�~�&�
'�5�	������
�_�_�U�
#��
�	�	�%������R� �5�
4�s�A
C�C+	�$C+	c��,oQFDdoQFDZo[OOV#2o[OOU2%fJIUO	U2J\	Jf	U%fUOQ2Qo[OOU2%c7[OO
U2%fUO	U2SFD�o[OQUP	[OQ5oU9^tt^2UOUOO2O2[UQ22PPP2J�	P!)%fhJ�9h)�/binz"bash or ksh required for this testz/bin/shzecho $0)r`rrIr�)r�z	/usr/bin/z/usr/local/bin)�bash�ksh)rrr�isfiler�r��islinkrrKrLrarIr2r�r8)r#�shellsr_rm�shrRs&     r�test_specific_shell�(POSIXProcessTestCase.test_specific_shell;
s�����=�F�'���W�W�\�\�&�/���7�7�>�>�"�%�%��M�M�"�%�(�>�
��M�M�>�?�
��
�7�7�>�>�"���b�g�g�n�n�R�&8�&8��M�M�"���B�� � ��r��(2���9�A���� � �������!6�!6�!8�%��G�:L�M�������s�AE.	�.E?
�7E?
c��[O[O[O2o[O[
OQQ,P	[O[O[OQ5o[O[OU2UOO]2[VA2UU![O[OS2h9h)rz�if 1:
                                 import sys, time
                                 sys.stdout.write('x\n')
                                 sys.stdout.flush()
                                 time.sleep(30)
                                 �r'rHrIrJ)r+�SIGINT�default_int_handlerrrKr_r`rLrIr2r)r#�methodr?r,rRs&&*  r�
_kill_process�"POSIXProcessTestCase._kill_processO
s���
�m�m�F�M�M�6�3M�3M�N��	6�� � �#�.�.�$�9%�"&�,0�'1���(2���(2���	9�A�
�M�M�&�-�-��5�	
���
�
�a�����D�!����
�M�M�&�-�-��5�s�AC�'Dz"Due to known OS bug (issue #16762)c�V�[O[OQQ,P	[O[O[OQ5oUO
O
]2[O]2[V12UUO2P!)rz�if 1:
                             import sys, time
                             sys.stdout.write('x\n')
                             sys.stdout.flush()
                             r�)rrKr_r`rLrIr2r:r�rr�)r#r�r?rRs&&* r�_kill_dead_process�'POSIXProcessTestCase._kill_dead_processh
ss��

���c�n�n�d�5!�"�
(,�#-�?�?�$.�O�O�$.�O�O�
5��	
���
�
�a���
�
�1�
����D�!�	�
�
�rc���UOQ[O2oUO2vq#UO	QU2UOUO
2]2P!)�send_signalsKeyboardInterrupt)r�r+r�r�rqrr)�r#rRr�rJs&   r�test_send_signal�%POSIXProcessTestCase.test_send_signal
sJ�����}�f�m�m�<���M�M�O�	���
�
�*�F�3����A�F�F�H�a�(rc���UOQ2oUO2vq#UOUQ2UOUO2[O
'2P!)r�r)r�r�rar)r+�SIGKILLr�s&   r�	test_kill�POSIXProcessTestCase.test_kill�
sK�����v�&���M�M�O�	�������%��������F�N�N�?�3rc���UOQ2oUO2vq#UOUQ2UOUO2[O
'2P!)�	terminater)r�r�rar)r+�SIGTERMr�s&   r�test_terminate�#POSIXProcessTestCase.test_terminate�
sK�����{�+���M�M�O�	�������%��������F�N�N�?�3rc�H�UOQ[O2P!�r�)r�r+r�r"s&r�test_send_signal_dead�*POSIXProcessTestCase.test_send_signal_dead�
s�����
�v�}�}�=rc�*�UOQ2P!�r��r�r"s&r�test_kill_dead�#POSIXProcessTestCase.test_kill_dead�
s������'rc�*�UOQ2P!�r�rr"s&r�test_terminate_dead�(POSIXProcessTestCase.test_terminate_dead�
s������,rc��,oSFDBo[OU2o[OU2oUOV5U12JD	U!r )r�get_inheritable�dupr�)r#�save_fdsr�r��inheritable�saveds&&    r�	_save_fds�POSIXProcessTestCase._save_fds�
sF�����B��,�,�R�0�K��F�F�2�J�E��J�J��;�/�0���
rc�~�SFD4vq#o[OV2UQ5[OU2J6	P!))r)r�dup2rP)r#r�r�rrs&&   r�_restore_fds�!POSIXProcessTestCase._restore_fds�
s*��&)�"�B�{��G�G�E�;�7��H�H�U�O�'*rc���]oUOU2oSFDvqEoU]6XfJSoL	SFDo[OU2J	[O[
OQQ,U[O[OQ5O2vqxUOUQ2UOUQ2UOU2P!SOS2h9h)rrr�rGr�rt)rrrPrrKr_r`rLr�rar)	r#r�rH�	saved_fdsr�rrr�r�s	&&       r�check_close_std_fds�(POSIXProcessTestCase.check_close_std_fds�
s������N�N�3�'�	�&/�"�B�{��Q�w����'0�	)���������!�'�'�����;�)<�
#�(�o�o�(�o�o�/�0;�{�}�
�C�
���S�(�+����S�)�,����i�(��D���i�(�s�BC�C0c�,�UO],2P!rw�rr"s&r�test_close_fd_0�$POSIXProcessTestCase.test_close_fd_0�
���� � �!��%rc�,�UO],2P!�r�rr"s&r�test_close_fd_1�$POSIXProcessTestCase.test_close_fd_1�
rrc�,�UO],2P!)r�rr"s&r�test_close_fd_2�$POSIXProcessTestCase.test_close_fd_2�
rrc�.�UO]],2P!rwrr"s&r�test_close_fds_0_1�'POSIXProcessTestCase.test_close_fds_0_1�
���� � �!�Q��(rc�.�UO]],2P!rwrr"s&r�test_close_fds_0_2�'POSIXProcessTestCase.test_close_fds_0_2�
r*rc�.�UO]],2P!r!rr"s&r�test_close_fds_1_2�'POSIXProcessTestCase.test_close_fds_1_2�
r*rc�.�UO,QN2P!)r)rr�r�rr"s&r�test_close_fds_0_1_2�)POSIXProcessTestCase.test_close_fds_0_1_2�
s��	
� � ��+rc��[O]2o[O]2o[O]2[O]2[O[
OQQ,2O2[OU]2[OU]2[OU2[OU2P![OS]2[OS]2[OS2[OS2h9h)z=Issue #15798: Popen should work when stdio fds are available.rz*print('AssertionError:0:CLOEXEC failure.'))	rr
rPrrKr_r`r)r)r#�	new_stdin�
new_stdouts&  r�test_small_errpipe_write_fd�0POSIXProcessTestCase.test_small_errpipe_write_fd�
s����F�F�1�I�	��V�V�A�Y�
�	!��H�H�Q�K��H�H�Q�K�

����N�N�D�@�B�
C�CG�4�6�
�G�G�I�q�!��G�G�J��"��H�H�Y���H�H�Z� ��
�G�G�I�q�!��G�G�J��"��H�H�Y���H�H�Z� �s
�A!C,�,AEc��[]2Tt,tFDo[O2MJ	ooSTTt,tFDvq4UMJ		oooSFDvq4[OU2J	[O
U]*Q2[OU]*]]2UO[]22o[U2FDvq7[OVs2J	[O[OQQ,U]*U]*U]*Q5oUO2UOU2SFDo[OU]]2J	[O U]*Q2o	[O U]*Q2O#2o
UO%U	Q2UO%U
Q2SFDo[O&U2J	P!ttohttoohSOS2h9hWFDo[O&S2J	h9h��sSTDINrzZimport sys; got = sys.stdin.read();sys.stdout.write("got %s"%got); sys.stderr.write("err")rGrzs	got STDINserr)rr�rr�unlinkr�rhr�	enumeraterrrKr_r`r)rr2r�rarP)r#r�tempsr�r��temp_fdsr�temp_fdrRr�r�s&          r�test_remapping_std_fds�+POSIXProcessTestCase.test_remapping_std_fds�
s���-2�1�X�6�X���!�!�#�X��6�(	�,1�2�E�y�r��E�H�2�#�	���	�	�%� �#�
�H�H�X�a�[�(�+��H�H�X�a�[�!�Q�'����u�Q�x�0�I�
-�#,�X�#6�K�B��G�G�G�(�$7�
�$�$�c�n�n�d�N�&O�#�1�+�#�A�;�#�A�;�(�������!�!�)�,�������Q��"���'�'�(�1�+�t�,�C��'�'�(�1�+�t�,�2�2�4�C����S�,�/����S�&�)����������Q7��2��6�!�!�)�,����������s<� G?�H �H�A<H �A;H
�<B!H �H �
H�H � "Ic�(�[]2Tt,tFDo[O2MJ	ooSTTt,tFDvqgUMJ		oooSFDvqg[OU2J	UO[]22o	[
U2FDvqj[OV�2J	[OUQ2[OU]]2[O[OQQ,UUUQ5oUO2SFDo[OU]]2J	[OUQ2o[OUQ2O!2o
UO#U	2UO%UQ2UO%U
Q2SFDo[O&U2J	P!ttohttoohSO#S	2h9hSFDo[O&S2J	h9hr:)rr�rrr<rr=rr�rhrrKr_r`r)r2r�rrarP)r#�stdin_no�	stdout_no�	stderr_norr>r�r�r?rr@rRr�r�s&&&&          r�check_swap_fds�#POSIXProcessTestCase.check_swap_fdss���-2�1�X�6�X���!�!�#�X��6�(-�.��9�2�B���.�'	�"�	���	�	�%� �#����u�Q�x�0�I�
-�#,�X�#6�K�B��G�G�G�(�$7�����8�,�����1�a�(��$�$�c�n�n�d�N�&O�#�$�$�&������"�B��H�H�R��A�&�#��g�g�i��.���g�g�i��.�4�4�6���!�!�)�,����S�,�/����S�&�)����������Q7��.��B�!�!�)�,����������s/� G�G�<G/�C3G�75G/�G,�,G/�/"Hc���UO]]]2UO]]]2UO]]]2UO]]]2UO]]]2UO]]]2P!rw)rGr"s&r�
test_swap_fds�"POSIXProcessTestCase.test_swap_fdsLsn�����A�q�!�$����A�q�!�$����A�q�!�$����A�q�!�$����A�q�!�$����A�q�!�$rc��UO[]22oSFDNo[O29^tt^2o[O
UO
2U2PPP2JP	[[]22[U2*
O2o[OU2,QNo-o[V2FDvqIVHVy*$J	[OQ2o
[[]22[U2*
O2o[O[O QU
[#U2,1-U@oUO%U]2[V2FD�vqI[O&U][O(2[O*UQ2o
[-[/[0U
O3Q222o[OQUQUQUQUQ	U	Q
02oUO%U	,V�2J�	UO5U2P!)%fhCJ$9hSO5S2h9h)r;z�
                import os, sys
                skipped_fd = int(sys.argv[1])
                for fd in range(3):
                    if fd != skipped_fd:
                        os.write(fd, str(fd).encode('ascii'))
            rrzr�z"
                    When testing z to z4 redirection,
                    parent descriptor z5 got redirected
                    to descriptor(s) z instead of descriptor z.
                rG)rrr�r�rrrgr]r�rP�ziprvrwrr^r_r`rrrarh�SEEK_SETr2r��maprr3r)r#�from_fds�to_fdsr�from_fd�f�fd_to_close�	arg_namesr@�to_fdr��
skipped_fdrc�
read_bytes�read_fdsrs&&&             r�#_check_swap_std_fds_with_one_closed�8POSIXProcessTestCase._check_swap_std_fds_with_one_closedTs����N�N�5��8�,�	�&	)�#���+�+�-�-���G�G�A�H�H�J��0�.�-�$��u�Q�x�=�3�x�=�8�=�=�?�K��H�H�[�!�5�I��F�"%�h�"7���+2�y�'�(�#8��?�?�$��D��e�A�h�-�#�f�+�5�:�:�<�J����#�.�.�$��c�*�o�!N�+�#)�+�B����R��#�"%�h�"7�������!�R�[�[�1��W�W�W�d�3�
���C��):�):�7�)C� D�E���o�o�+"�"*��4��x�8'�'.�i�0&�&.�Z�/F�u�g�N�'���
� � �%��(�8�#8�
���i�(�I.�-�-��H
���i�(�s*�#I�&H2	�&F9I�2I
�;I
�=
I�Ic���[O[]2]2FD<o[O[]2]2FDoUO	V2J	J>	P!)r;)�	itertools�combinationsr�permutationsrZ)r#rPrQs&  r�!test_swap_std_fds_with_one_closed�6POSIXProcessTestCase.test_swap_std_fds_with_one_closed�sF��!�.�.�u�Q�x��;�H�#�0�0��q��1�=���8�8��J�>�<rc��Qo[O[UQ5UOQ2P![cFoSO[O2SO[S2Q2Po=P!Po=h[OcFoSO[O2SO[S2Q2Po=P!Po=hh9h)c��[Q2g)�
surrogate:�r�r0rr�prepare�CPOSIXProcessTestCase.test_surrogates_error_message.<locals>.prepare�s���/�0�0rr�z1Expected ValueError or subprocess.SubprocessErrorrdz!Exception occurred in preexec_fn.)rr^rrpr�rr�rarrr��assertIsNotNone)r#rer�s&  r�test_surrogates_error_message�2POSIXProcessTestCase.test_surrogates_error_message�s���	1�
	K��O�O��"�
$�
�I�I�I�J���	;����j�3�3�4����S��X�'9�:�:���)�)�	L�� � ��!6�!6�7����S��X�'J�K�K��	L�s,�5�	C�C�:B�C�C�:C�Cc���Q
FCDavqUOQQ2oQ[U2*o[OO	2oV%U$QUQ$So[
O[OQU,UQ5oUOQ2oUOUOQ2[U22UOQQ2oQ	[U2*o[OO	2oV5U$[
O[OQU,UQ5oUOQ2oUOUOQ2[U22CJd	P!)�testr�r�z&import os; print(ascii(os.getenv(%s)))�C�LC_ALLrr�s

z'import os; print(ascii(os.getenvb(%s)))))rkuabc�)utest��42)
r'rrr�r�rr�r_r`r�rar3r�)r#�key�value�
encoded_value�scriptr��
decoded_valuerIs&       r�test_undecodable_env�)POSIXProcessTestCase.test_undecodable_env�s-��G�J�C�!�L�L��2C�D�M�>��S�	�I�F��*�*�/�/�#�C���H� �C��M�!�M��,�,�����v�.���F��]�]�7�+�F����V�]�]�7�3�U�=�5I�J��*�*�W�&7�8�C�>��c��J�F��*�*�/�/�#�C�$��H��,�,�����v�.���F��]�]�7�+�F����V�]�]�7�3�U�=�5I�J�5Hrc�z�[O[]*2o[[Q*2o[OO[]*2vq4[OU2o[OU,U*2oUOU]2QUQOU2OQ21*o[OUP	Q5oUOU]2[OO2oV7Q$[OU,U*UQ5oUOU]2[OO2o[OU2UQ$[OU,U*UQ5oUOU]2P!)	r�r�NNs'%s' %s� r�r�PATHr�sPATH)rrrr�rr,rr^rarr'r�r��environb)	r#�abs_programr?r�program�exitcoder�r��envbs	&        r�test_bytes_program�'POSIXProcessTestCase.test_bytes_program�sA���k�k�/�!�"4�5���O�B�'�(�����
�
�o�a�&8�9�
���+�+�g�&���?�?�K�=��#5�6������1�%��K����$��)>�)>�w�)G�H�H���?�?�3�d�3������1�%��j�j�o�o����F���?�?�G�9�T�>�s�;������1�%��{�{���!�����D�)��W�
��?�?�G�9�T�>�t�<������1�%rc�$�[OQQQ5o[OQQQ5o[O[O
U,[O[O[OP
Q5oUOUOQ2[O[O
U,[OP
Q5oUO2vqV[[[UOQ222o[UOO2UOO2UO O2,2oUO#Vx*QU8Q	Vx*802P!)
zinput_reader.py�subprocessdata��subdir�fd_status.py)rHrIrJr'r�rIr'�,zExpected no fds from z to be open in child, found )r�findfilerrKr_r`rLr�r�r]rOrr,rHrgrIrJr+)	r#�sleeper�	fd_status�p1�p2r��error�
result_fds�unwanted_fdss	&        r�test_pipe_cloexec�&POSIXProcessTestCase.test_pipe_cloexec�s���"�"�#4�=M�N���$�$�^�<L�M�	�
�
�
�s�~�~�w�7�$.�O�O�J�O�O�%/�_�_��G��	
�������,�
�
�
�s�~�~�y�9�%/�_�_��G�����(�
����S�&�,�,�t�"4�5�6�
��B�H�H�O�O�-�r�y�y�/?�/?�/A��I�I�,�,�.�0�1��	
����2� ,�Z�-F�H�	Irc�`
`�[OQQQ5o[OQQQ5oQoU]*Q*o[O[O
U,[O[OP
Q5n
[O[O
V#,R
O[OP
Q5nUOR
O2UORO2U
1QkoU1QkoUOU2UOU2R
OOU2R
OO2[ORO,,,]
2vqxo	UOUQ	2UOROO!2U2R
OO2ROO2P!)
zqcat.pyr�r�zqgrep.pyszxcvbn�
)rHrIr'c�P:�RO2P![cP!h9hr �r��ProcessLookupError)r�s�r�kill_p1�BPOSIXProcessTestCase.test_pipe_cloexec_real_tools.<locals>.kill_p1��#���
������%�
��
����	%�%�%c�P:�RO2P![cP!h9hr r�)r�s�r�kill_p2�BPOSIXProcessTestCase.test_pipe_cloexec_real_tools.<locals>.kill_p2�r�r�zThe child hung)rr�rrKr_r`rLrIr�r)rHr�rPrrPrar2)r#�qcat�qgrep�subdatar�r�r��	readfiles�ignored1�ignored2r�r�s&         @@r�test_pipe_cloexec_real_tools�1POSIXProcessTestCase.test_pipe_cloexec_real_tools�s]������	�2B�C��� � ��4D�E������{�U�"��
�
�
�s�~�~�t�4�$.�O�O�J�O�O�(-�/���
�
�s�~�~�u�>�$&�I�I�j�o�o�(-�/��	
������ ������� �	�
	�
	
���� ����� �
�����t��
������(.�
�
�r�y�y�k�2�r�2�(N�%�	�X����	�#3�4���������)�4�0�
�	�	����
�	�	���rc�b`
�[OQQQ5o[O2oUO	[O
U]*2UO	[O
U]*2[
U2n
[]	2FDgo[O[O[O2oUO	[O
U2R
OU2Ji	R
FDo[OUP	2J	[O[O U,[O"P
Q5oUO%2vqg[
['[(UO+Q222oUO-UR
*R
Q2[O[O U,[O"P	Q5oUO%2vqg[
['[(UO+Q222oUO/UR
*Q2UO1]UQ2[9PIc.U
1Qk[]22DjJ	LU
1Qk[]222o	[O[O U,[O"P	U	Q	5oUO%2vqg[
['[(UO+Q222oUO/V�*
R
*Q
2UO1]UQ2P!)r�r�r�r�r�zSome fds were closedzSome fds were left openzSubprocess failedc3�P:�SF �DoRO2w�	J	P!3hr )r�)�.0r�r�s& �r�	<genexpr>�6POSIXProcessTestCase.test_close_fds.<locals>.<genexpr>4s��(���(�Q�(�,�,�.�.�(�s�&�rIr'�pass_fdsz'Some fds not in pass_fds were left open)rr�rr�r�rPr]rr��devnullr��add�set_inheritablerrKr_r`rLr�rOrr,rar+rq)r#r�r�r�r�rRr��ignored�
remaining_fds�fds_to_keepr�s&         @r�test_close_fds�#POSIXProcessTestCase.test_close_fdss:����$�$�^�<L�M�	��g�g�i��������#�a�&�)�������#�a�&�)��s�8���q��A�������R�[�[�1�B��O�O�B�H�H�b�)��L�L����
�B����r�4�(��
���c�n�n�i�8�$.�O�O�u�
F���-�-�/����C��V�\�\�$�%7�8�9�
������1�8�/�	1�
���c�n�n�i�8�$.�O�O�t�
E���-�-�/����C��V�\�\�$�%7�8�9�
������1�2�	4��
�
�a��(;�<��c�;�%��(�;�c�c�;�%��(�;�;�����c�n�n�i�8�$.�O�O�t�&1�
3���-�-�/����C��V�\�\�$�%7�8�9�
����-�5��A�B�	D��
�
�a��(;�<r�freebsdz/devz/dev/fdz.Requires fdescfs mounted on /dev/fd on FreeBSDc��[OQQQ5o[O[O
Q[OQU*2,[OQ5oUO2vq4UO2oUO[U2]QU*Q5[[[U]*O!2O#Q	222o[[[U]*O!2O#Q	222oUO%Vv*Q
Q5P!)z;Confirm that issue21618 is fixed (may fail under valgrind).r�r�r�raK
        import os, resource, subprocess, sys, textwrap
        open_fds = set()
        # Add a bunch more fds to pass down.
        for _ in range(40):
            fd = os.open(os.devnull, os.O_RDONLY)
            open_fds.add(fd)

        # Leave a two pairs of low ones available for use by the
        # internal child error pipe and the stdout pipe.
        # We also leave 10 more open as some Python buildbots run into
        # "too many open files" errors during the test if we do not.
        for fd in sorted(open_fds)[:14]:
            os.close(fd)
            open_fds.remove(fd)

        for fd in open_fds:
            #self.addCleanup(os.close, fd)
            os.set_inheritable(fd, True)

        max_fd_open = max(open_fds)

        # Communicate the open_fds to the parent unittest.TestCase process.
        print(','.join(map(str, sorted(open_fds))))
        sys.stdout.flush()

        rlim_cur, rlim_max = resource.getrlimit(resource.RLIMIT_NOFILE)
        try:
            # 29 is lower than the highest fds we are leaving open.
            resource.setrlimit(resource.RLIMIT_NOFILE, (29, rlim_max))
            # Launch a new Python interpreter with our low fd rlim_cur that
            # inherits open fds above that limit.  It then uses subprocess
            # with close_fds=True to get a report of open fds in the child.
            # An explicit list of fds to check is passed to fd_status.py as
            # letting fd_status rely on its default logic would miss the
            # fds above rlim_cur as it normally only checks up to that limit.
            subprocess.Popen(
                [sys.executable, '-c',
                 textwrap.dedent("""
                     import subprocess, sys
                     subprocess.Popen([sys.executable, %r] +
                                      [str(x) for x in range({max_fd})],
                                      close_fds=True).wait()
                     """.format(max_fd=max_fd_open+1))],
                close_fds=False).wait()
        finally:
            resource.setrlimit(resource.RLIMIT_NOFILE, (rlim_cur, rlim_max))
        r�z(expected exactly two lines of output:
%rrr�zSome fds were left open.)rr�rrKr_r`rvrwrLr�r�rarr]rOrr�r,r+)r#r�rRr��
unused_stderr�output_lines�
opened_fdsr�s&       r�%test_close_fds_when_max_fd_is_lowered�:POSIXProcessTestCase.test_close_fds_when_max_fd_is_lowered@s��
�$�$�^�<L�M�	�
���c�n�n�d�H�O�O�/	�^�_/	�05�0�`#-�/�/�a0
3��d!"�
�
�����(�(�*������\�*�A�H�6�Q�	�	S���S�,�q�/�"7�"7�"9�"?�"?��"E�F�G�
��C��\�!�_�%:�%:�%<�%B�%B�4�%H�I�J�
�����3�7�	�	9rc�L�[OQQQ5o[2o[]2FD�o[O
2oUO
[OU]*2UO
[OU]*2[OU]*P	2[OU]*P	2UOU2J�	SFCD"o[O[OU,[OP	U1Q5oUO2vqx[[!["UO%Q222o	V%.*
o
UO'VYQ2UO)V�*Q2UO+[,29^tt^2oUO)[O.[0P
U1Q52PPP2UO'Q[3WO422CJ%	P!)%fhK<9h)	r�r�r�r�r�zfd to be passed not passedzfd to be closed passed)r'r�zoverriding close_fds)rr�r]rrr�r�rPr��updaterrKr_r`rLr�rOrr,rqr+�assertWarnsr�r^rrr�warning)r#r�r�r^r�r�rRr�r�r��to_be_closed�contexts&           r�
test_pass_fds�"POSIXProcessTestCase.test_pass_fds�s����$�$�^�<L�M�	��5���q��A��'�'�)�C��O�O�B�H�H�c�!�f�-��O�O�B�H�H�c�!�f�-����s�1�v�t�,����s�1�v�t�,��O�O�C� �
��B�� � �#�.�.�)�!<�(2���4�+-�&�2�A� �m�m�o�O�F���C����d�);� <�=�M�#�d�?�L��M�M�"�-I�J����]�9�5�
7��!�!�.�1�1�W�� � ����'�"'�2�&�":�;�2�
�M�M�0�#�g�o�o�2F�G�%�2�1�s�1.H	�H#
�H#
c�N�[OQQQ5o[O2vq#UO	[O
U2UO	[O
U2[OUP	2[OUP
2V#1o[OU,oU[[[U22*
o[OU[OP	UQ5oUO2vqx[![["UO%Q222o	UO'U	[!U2QU*2UO'[O(U2P	2UO'[O(U2P
2P!)r�r�r�r�r�z	output=%a)rr�rr�r�rPr�r_r`r�rOrrrrKrLr�r]rr,rar)
r#rrr�non_inheritabler�r?rRr�r�r�s
&         r�test_pass_fds_inheritable�.POSIXProcessTestCase.test_pass_fds_inheritable�s/���!�!�.�9I�J��')�w�w�y�$��������+�.�������/�2�
���;��-�
���?�E�2��1������'����S��h�'�(�(�����T�$.�O�O�t�&.�
0���-�-�/����#�c�6�<�<��-�.�/��	
����c�(�m�[�6�-A�B�	
����+�+�K�8�$�?�����+�+�O�<�e�Drc	��[OQQQ5o,o[]2FDgo[O[O
[O2oUO[OU2UOU2Ji	[O2vqVUO[OU2UO[OU2UO]U2[O[OU,U]*U]*U]*P	UQ59^tt^2[O UQ2oPPP2WO#Q2Tt.tFDo[%U2jJ	o	oUO'U	.Ql[)U2*QU802P!)%fhKe9httoh)	z7Regression test for https://bugs.python.org/issue32270.r�r�r�)rHrIrJr'r�rzr�zoutput=>rr�r�)rr�rrr�r��O_RDWRr�rPr�r��insertrrKr_r`r2r,rra�	frozenset)
r#r�r�r�r��stdout_r�stdout_wr��numr�s
&         r�test_pass_fds_redirected�-POSIXProcessTestCase.test_pass_fds_redirected�sG���$�$�^�<L�M�	����q��A�������R�Y�Y�/�B��O�O�B�H�H�b�)��O�O�B���
 �W�W�Y���������(�+�������(�+�����8�$�
�
�
�s�~�~�y�9�$,�Q�K�%-�a�[�%-�a�[�(,�'/�1�1��W�W�X�t�,�F�
1�$*�<�<��#5�6�#5�C�s�3�x�#5��6�����i�)�H�*=�=���
�?S�T�1�1��7s�F:�7G
�:G
	�G
	c���[O[OQ29^tt^2o[O
[VQ5oUO2PPP2P!)%fhP!9h)�r+)rIrH�rNr�rr�rrKrr)�r#�inoutrRs&  r�%test_stdout_stdin_are_single_inout_fd�:POSIXProcessTestCase.test_stdout_stdin_are_single_inout_fd��F��
�W�W�R�Z�Z��
&�
&�%�� � ��(-�<�A�
�F�F�H�'�
&�
&�
&���-A&�&A7	�/A7	c���[O[OQ29^tt^2o[O
[VQ5oUO2PPP2P!)%fhP!9h)r�r�r�r�s&  r�&test_stdout_stderr_are_single_inout_fd�;POSIXProcessTestCase.test_stdout_stderr_are_single_inout_fd�sF��
�W�W�R�Z�Z��
&�
&�%�� � ��(-�=�A�
�F�F�H�'�
&�
&�
&�r�c���[O[OQ29^tt^2o[O
[VQ5oUO2PPP2P!)%fhP!9h)r�)rJrHr�r�s&  r�%test_stderr_stdin_are_single_inout_fd�:POSIXProcessTestCase.test_stderr_stdin_are_single_inout_fd�r�r�c�L�[OQQQ5o[O[O
U,[O[OQ5oUO2vq4UO]UOQUOQ2*2P!)zsigchild_ignore.pyr�r�r�z6sigchild_ignore.py exited non-zero with this error:
%sr�)rr�rrKr_r`rLr�rarr3)r#�sigchild_ignorerRrIrJs&    r�test_wait_when_sigchild_ignored�4POSIXProcessTestCase.test_wait_when_sigchild_ignored�s{��!�*�*�+?�2B�D�����c�n�n�o�>�$.�O�O�J�O�O�
M������������A�L�L�+:����w�/�+0�	1rc	���[OQ2o[O[O
QQ,[O]Q5oUOoUOUO2UOUO]2Q2UOV1OU,,,Q2]*2UO2P!SO2h9h)rrz$import sys;sys.stdout.write("apple"))rIrVsapplg)r�
import_modulerrKr_r`rLrIr�rPrar2rqrr))r#rrRrSs&   r�test_select_unbuffered�+POSIXProcessTestCase.test_select_unbuffered

s����,�,�X�6�����c�n�n�d�:�;�%/�O�O�%&�	
(��

�H�H�������� �	����Q�V�V�A�Y��0��M�M�!�]�]�A�3��B��<�Q�?�@�
�F�F�H��A�F�F�H�s
�8A
C�C)c
��[O[OQQ,[O[OQ5oUOUOO2UOUOO2[U2oUOo[OP[129^tt^2PoPPP2[%c"UO[O 2P!SO#S[O Tt,tFDo[U2MJ	to2P!)%fhKy9httoh)rz import sys, time;time.sleep(0.2)r�)rrKr_r`rLr�rIrPrJ�idr9r�check_warnings�ResourceWarningr'rr(rq)r#rR�identr9�os&    r�test_zombie_fast_process_del�1POSIXProcessTestCase.test_zombie_fast_process_del
s���

���c�n�n�d�0�1�%/�O�O�$.�O�O�	
5��
	
��������'���������'��1����e�e��
�
+�
+�R��,A�
B�
B��A�C��9����j�0�0�1�
�M�M�%��1C�1C�!D�1C�A�"�Q�%�1C�!D�E�C�
B��"Es�
E�"E
�E	�
E	c
��[O[OQQ,[O[OQ5oUOUOO2UOUOO2[U2oUOo[OP[129^tt^2Po[O2PPP2[ O"U[$O&2[(%c!UO+[O,2L:SO/S[O,Tt,tFDo[U2MJ	to2[0O2Q2UO5[629^tt^2[O[8[O[OQ59^tt^2oPPP2PPP2UO5[6[ O:U]2[(%c"UO+[O,2P!SO=S[O,Tt,tFDo[U2MJ	to2P!)%fhCK�9httoh)%fhK�9h)%fhK�9httoh)rzimport time;time.sleep(3)r�r1)rrKr_r`rLr�rIrPrJr�r9rr�r�r�
gc_collectrr�r+r�r'rr(rqr:r�rkr�r�waitpidr�)r#rRr�r9r�r�s&     r�!test_leak_fast_process_del_killed�6POSIXProcessTestCase.test_leak_fast_process_del_killed3
s���
���c�n�n�d�.�/�%/�O�O�$.�O�O�	
5��
	
��������'���������'��1����e�e��
�
+�
+�R��,A�
B�
B��A���� �C�	����V�^�^�$��9����j�0�0�1�
�M�M�%��1C�1C�!D�1C�A�"�Q�%�1C�!D�E�	
�
�
�3��
�
�
�w�
'�
'��!�!�/�)3���)3���:�:�=A��:�(�	
���'�2�:�:�s�A�6��9����j�0�0�1����U�J�4F�4F�$G�4F�q�R��U�4F�$G�H�5C�
B�
B��"E�:�:��(�
'��%HsO�
J�J"
�+AJ:�-J'	�/J:�/K
�J	�J	�'J7
�0J7
�2J:�:K
	�K
	c�`�[OQQQ5o[O]2nUO	[O
R2[O[OU,[OP	U1QkQ5oUO2vq4[[[UOQ222oUO!RU2P!)r�r�r�c�4:�[O]R2!r!)rr)r�s�rr��CPOSIXProcessTestCase.test_close_fds_after_preexec.<locals>.<lambda>h
s�������2�r)rIr'r�r�)rr�rr
r�rPrrKr_r`rLr�r]rOrr,r�)r#r�rRr�r�r�r�s&     @r�test_close_fds_after_preexec�1POSIXProcessTestCase.test_close_fds_after_preexec^
s�����$�$�^�<L�M�	��V�V�A�Y��������"�%����c�n�n�i�8�$.�O�O�t�(>�
@���-�-�/����C��V�\�\�$�%7�8�9�
�����]�+rc�J�]PHo[O2oQo[O2]{Q,PQ,1Q,]{PQ,1Q,Q,]{Q,1Q,Q,P]{11FDvvqEqgUO	[
29^tt^2oUO
VEP	QVgPPPP]]]]P	P	]P
,]PUP
2PPP2UOQ[WO22Jx	U%f[O2P!P!)%fhKZ9hS%f[O2hh9h)rc��P!r r0r0rrr��5POSIXProcessTestCase.test_fork_exec.<locals>.<lambda>y
s��4rsexe�envsargz
takes exactlyr0)�_posixsubprocessr�r�r�rkr�r�r�rrr}r�)	r#r��
gc_enabled�funcr?�exe_listr'�env_listr�s	&        r�test_fork_exec�#POSIXProcessTestCase.test_fork_execo
s ��	 ��\�\�^�
� 	� �D��I�I�K��F�8�T�F�8�4���3�T�F�8�4���F�8�S�F�8�4���F�8�T�3�/�	2�-����&�&�y�1�1�S�$�.�.���b�#��B��B��1�a���d�A��r�1�b��e�%�2� � � ��#�c�m�m�2D�E�-2�0��
�
���%2�1��$��
�
���s0�AD�7&C/	�1D�/C?
�8C?
�:D�D"�D"c�j�]PHoQQ2o[O2o[O2QQ	Q
QQU]2U]211FD�oUO	[
QO
U2Q59^tt^2oUOQ,Q,P	UPQ,PPPP]]]]P	P	]PPPPP2PPP2UOQ[WO22J�	U%f[O2P!P!)%fhKZ9hS%f[O2hh9h)
rc�2`�\sQsQsnP	sQsQsQsUsP!)�JPOSIXProcessTestCase.test_fork_exec_sorted_fd_sanity_check.<locals>.BadInti�
c��VmP!r )rp)r#rps&&rr��SPOSIXProcessTestCase.test_fork_exec_sorted_fd_sanity_check.<locals>.BadInt.__init__�
s��"�
rc�Z�UO%cP
UmUO![g)F)�firstrpr�r"s&r�__int__�RPOSIXProcessTestCase.test_fork_exec_sorted_fd_sanity_check.<locals>.BadInt.__int__�
s"���:�:�:�!&�D�J��:�:�%� � r)rrp)	r2r3r4r5rr�rr6r7r8s@r�BadIntr�
s�����E�
#�
!�
!rrzfds_to_keep={}rsfalser�r�)���r�r;��)rrr)���*l)rr)��rr�)r�r�r�r�rkr�r�r�rqrrr}r�)r#r�rr�r�rs&     r�%test_fork_exec_sorted_fd_sanity_check�:POSIXProcessTestCase.test_fork_exec_sorted_fd_sanity_check�
s#��	 �	!�	!��\�\�^�
�	��I�I�K�!��#������F�1�I�&�
 ���&�&�"�,�3�3�K�@�'�B�B�EF�$�.�.�!�
�X�J��k�4�&���B��B��1�a���d�A��d�D�"���B��
�
�m�S����-=�>�' �*��
�
���B�B����
�
���s0�AD�*C?	�-1D�?D
�D
�
D�D2�D2c	��[O[2oS9^tt^2[OOUQ29^tt^2o[UOmUO2UOO2PPP2PPP2P!)%fhK9h)%fhP!9hr�)rrKrrrr�BrokenPipeErrorrPr�r��assert_called_with�r#r��mock_proc_stdins&  r�,test_communicate_BrokenPipeError_stdin_close�APOSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_close�
st������0��
�T�4�:�:�$�$�T�7�3�3��0?�O�!�!�-������!�!�4�4�6�4�T�T�3�3��T�T�T�s0�)B4�AB!	�B4�!B1
�*B1
�,B4�4C	�=C	c	���[O[2oS9^tt^2[OOUQ29^tt^2o[UOmUOQ2UOOQ2UOO2PPP2PPP2P!)%fhK9h)%fhP!9h)rH�stuff)rrKrrrrrr�r�r�rSrPrs&  r�,test_communicate_BrokenPipeError_stdin_write�APOSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_write�
s�������0��
�T�4�:�:�$�$�T�7�3�3��0?�O�!�!�-����X�&��!�!�9�9�(�C��!�!�9�9�;�	4�T�T�3�3��T�T�T�s0�)C�AB=	�+C�=C

�C

�C�C!	�C!	c��[O[OQ,[O[OQ5oS9^tt^2[
OOUQ29^tt^2o[[OQ29^tt^2o[UOm
UO2UOmUO!Q2UOO#2PPP2PPP2PPP2P!)%fhK"9h)%fhK-9h)%fhP!9h)�-hr�rH�wbr!)rrKr_r`rLrrrr�rr�rrlr�rgrQr�rS)r#r�r�dev_nulls&   r�,test_communicate_BrokenPipeError_stdin_flush�APOSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_flush�
s���������� 6�&0�o�o�'1���8���T�4�:�:�$�$�T�7�3�3���R�Z�Z��&�&�(�0?�O�!�!�-�2:�/�/�2C�O�"�"�/����X�&��!�!�9�9�;�
'�4�T�T�&�&��4�3��T�T�T�sO�)D=�:#D*	�A D
�=D*	�D=�D'� D'�"D*	�*D:
�3D:
�5D=�=E	�E	c	���[O[OQ,[O[OQ5oS9^tt^2[
OOUQ29^tt^2o[UOm
UOQQ5UOO2PPP2PPP2P!)%fhK9h)%fhP!9h)r%r�rH��ri)
rrKr_r`rLrrrrrPr�r�rSrs&  r�9test_communicate_BrokenPipeError_stdin_close_with_timeout�NPOSIXProcessTestCase.test_communicate_BrokenPipeError_stdin_close_with_timeout�
s���������� 6�&0�o�o�'1���8���T�4�:�:�$�$�T�7�3�3��0?�O�!�!�-����S��)��!�!�9�9�;�	4�T�T�3�3��T�T�T�s1�)C!�:AC	�<C!�C
�C
�C!�!C2	�*C2	�
W_STOPCODEzneed _testcapi.W_STOPCODEc��[o[OU2o[OUO
]Q5[O]2o[OQUO
U1Q59^tt^2UO2oPPP2UOWQ2P!)%fhK$9h)zATest wait() behavior when waitpid returns WIFSTOPPED; issue29335.�r}r�rP���)rrrKr�wait_processr9�	_testcapir.rrr)ra)r#r?r��statusrs&    r�test_stopped�!POSIXProcessTestCase.test_stopped�
s���
������%��	���T�X�X��2��%�%�a�(��
�Z�Z�/�t�x�x��>P�
Q�
Q�����J�R�	
����R�(�R�
Q�s�B/�/B?	�8B?	c��[O[2o[OUO
]Q5UO
UO2[OQ29^tt^2oUO[O2PPP2WO2UOUO2P!)%fhK=9h)rr0zos.kill)rrKrrr2r9rrrrr�r+r��assert_not_calledrg)r#r��	mock_kills&  r�test_send_signal_race�*POSIXProcessTestCase.test_send_signal_races�������0��	���T�X�X��2�	
���$�/�/�*�
�Z�Z�	�
"�
"�i����V�^�^�,�#�
	�#�#�%�	
���T�_�_�-�#�
"�s�7 C�C	�C	c��[O[OQQ,2oUO%fUO2J$[OOUQQQ59^tt^2PUmUO[O2PPP2UO2P!)%fhK"9h)rzexit(1)r�c��P!r r0r0rrr��=POSIXProcessTestCase.test_send_signal_race2.<locals>.<lambda>s��dr��new)
rrKr_r`rr�rrrr�r+r�r�rQs& r�test_send_signal_race2�+POSIXProcessTestCase.test_send_signal_race2s��
���c�n�n�d�I�>�?���,�,�,�
�F�F�H�
�Z�Z�
�
�q�&�l�
�
;�
;��A�L�
�M�M�&�.�.�)�<�	
����<�
;�s�8'B9�9C		�C		c���[O[OQQ,[OQ5oUOQQ5P![OcJ.h9h)rz+import os, time; os.close(1), time.sleep(2)r�rhri)rrKr_r`rLr�rl�r#r�s& r�1test_communicate_repeated_call_after_stdout_close�FPOSIXProcessTestCase.test_communicate_repeated_call_after_stdout_close$s`���������!N�!P�'1���8���
�� � �� �-����,�,�
��
�s�A�A(�#A(�'A(c��Q[Q0o[QU2vq#oUOUO2Q2UO	QU2P!)z�if 1:
        import atexit
        import subprocess

        def dummy():
            pass

        class AtFinalization:
            def __del__(self):
                print("OK")
                subprocess.Popen(zu, preexec_fn=dummy)
                print("shouldn't be printed")
        at_finalization = AtFinalization()
        rsOKs0preexec_fn not supported at interpreter shutdown)rr	rar�rq)r#r�r�r�r�s&    r�test_preexec_at_exit�)POSIXProcessTestCase.test_preexec_at_exit/sR��
"�#2�!2�3	�
��'�t�T�2�����������e�,��
�
�I�3�Or�
HAVE_VFORKz!vfork() not enabled by configure.zsubprocess._USE_POSIX_SPAWNr?c�h�QoQ,oUOQQ59^tt^2[OQU8Q0U2oUOUOQ2PPP2QQPQ[
O20P	1Q	PQ
[
O20P	1Q1FDjvqEqgUOUQ59^tt^2[OQUQU8Q
UQUQ0	U2oUOUOQ2PPP2Jl	P!)%fhK�9h)%fhJ�9h)z	/bin/truez--trace=%process�default_is_vfork)rmzI                import subprocess
                subprocess.check_call([z])s	(?i)vfork�setgidzgroup=�setuidzuser=z:                    import subprocess
                    zj
                    try:
                        subprocess.check_call(
                                [z
], **dict(zN))
                    except PermissionError:
                        if not z#:
                            raise)�preexecr�zpreexec_fn=lambda: NoneF)rNr�zextra_groups=[]T)	r-r�
strace_python�assertRegex�event_bytesr�getgid�getuid�assertNotRegex)	r#�true_binary�strace_args�vfork_result�sub_name�preamble�sp_kwarg�expect_permission_error�non_vfork_results	&        r�test_vfork_used_when_expected�2POSIXProcessTestCase.test_vfork_used_when_expectedBsE��""��)�*��
�\�\�1�\�
2�
2�(�6�6�(�(3��b�<��	�L�
���\�5�5�}�E�3�B��2���	�	��}�5�t�<��2��r�y�y�{�m�4�d�;�:�	F
�A�H�����8��,�,�#0�#>�#>���J�"�#.��
�8�*�E � 7�8�9"�%� �$� ��#�#�$4�$@�$@�-�P�-�,�
F
�3�
2��(-�,�,�s$�9D
�=AD 	�
D	�D	� D1
�)D1
)r�)�netbsd�openbsd)zr2r3r4r5r$r�r�r�r�rrKr�rrr�rr�r]rrrrrrbrcrr7r<rIrLrRrUrQrdr'rorsr{rr�r�r�r�r�r�r_r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	rrrrr"r%r(r,r/r2r7rArGrJrZr`rhrtrr�r�r�rj�st_devr�r�requires_mac_verr�r�r�r�r�r�r�r�r�r�r��cpython_onlyrrrr"r(r,r3r5r:rArErHr`rdr�requires_stracer^r6r7�
__classcell__�r�r9s@@rr�r�sg����>�!�
B�
B�B�*�J�,�,��
�Z�Z�'�(�A�)�A� 
�Z�Z�'�(�:�)�:�*�_�_������(;�<�<�-�/�4�/�4�,7� �����Y�/�J�J�G�B�	�4J�<�>�9�>�9� �����Z�0�2K�L�1F�M�1F�f�_�_�W�R��,�.P�Q�?�R�?������Z�0�2M�N�'I�O�'I�R�_�_�W�R��,�.P�Q�@�R�@������[�1�3O�P�E�Q�E�
�����[�1�3O�P�F�Q�F�A�@8��_�_�Y�:�:�g�b�'�&:�":�6�8�&�8�&�(8�	9�?�
?�
	8�0� %��!1�!1�%�2�_�_�������4�4�6K�L�E�M�E��*�_�_����� �"E�G�L�G�L�(+�	,�L�L�!�N�(�2�_�_�S�\�\�,�,�-B�C�9�;��;��*)�4�4�>�(�-���
)�2&�&�&�)�)�)�,�
!�*+�Z+�`%�()�XK�
K�&K�:&�6I�.'�R-=�`�_�_�S�\�\�,�,�Y�7�I�I��W�W�V�_�+�+�r�w�w�y�/A�/H�/H�H�E�G�I9�G�I9�`
���b�!�$�H�%�H�BE�<U�4���	1��"F�0)I�V,�"
���%��%�N
���'��'�R7�<�
<�
<�����$�.�>�>�$�Y��=�4�6�)�6�)�.�,�	�P�&�_�_��1�1�,�?�?�8�:��"�"�$�	�Z�Z�-�5�9�2Q�:�%�:�2Q�2Qrr�zWindows specific testsc��`�\sQsQsnQsQsQs\OQ2Q2s	Qs
\OQ2sQ	s
Q
sQsQsQ
sQsQsQsQsQsQsQsQsQsQsQsQsUsP!)�Win32ProcessTestCasei{c��]o]o[O2oVmV#m[O[
UQ5P!)r�r�)r�STARTUPINFO�dwFlags�wShowWindowr^r)r#�STARTF_USESHOWWINDOW�SW_MAXIMIZEr�s&   r�test_startupinfo�%Win32ProcessTestCase.test_startupinfo~s<�� !���� �,�,�.��2��"-��	����$/�	1rc�x�]o]o[OUUQ5o[O[UQ5P!)r�)rlrmr�)rrkr^r)r#�STARTF_USERSHOWWINDOWror�s&   r�test_startupinfo_keywords�.Win32ProcessTestCase.test_startupinfo_keywords�s8��!"���� �,�,�)�#�
��	����$/�	1rc��[O2o[OUm[OUm[
]2FCD_o[o[[OQ29^tt^2o[OUU[OUQ5oU9^tt^2UO2PPP2UOUO]2PPP2UOUO[O2UO!UO"2UO!UO$2UO!UO&2UOUO
[O2UOUO(Q,-2CJb	P!)%fhK�9h)%fhK�9h)r�r�)rIrJr��handle_list)rrkrnrl�SW_HIDErmrrr�rr�rKr�r�rarr�	hStdInput�
hStdOutput�	hStdError�lpAttributeList)r#r�r�r��nullr�s&     r�test_startupinfo_copy�*Win32ProcessTestCase.test_startupinfo_copy�sN�� �,�,�.��(�=�=���",�"4�"4����q���A�!�C��b�j�j�#�&�&�$�!�'�'��/3�/9�/@�/@�4?�A���T��$�$�&��� � ����!�4�'�
���[�0�0�'�<�<�
>����k�3�3�4����k�4�4�5����k�3�3�4����[�4�4�j�6H�6H�I����[�8�8�=�"�:M�N�#��T��'�&�s0�93G	�,F3
�=$G	�3G�<G�>G	�G
�G
�guic���]o[OOQ2[O[O
Q*UQ5o[OU2UOU]2P!)�z'    a DOS box should flash briefly ...
z# -c "import time; time.sleep(0.25)"r�)	r_rJr�rr^r`r�*skip_on_low_desktop_heap_memory_subprocessra)r#�CREATE_NEW_CONSOLErcs&  r�test_creationflags�'Win32ProcessTestCase.test_creationflags�s]�� ���
�
���C�D�
�_�_�S�^�^�B�C�+=�?��	�:�:�2�>�����Q�rc�z�UO[[O[O
QQ,QQ5P!)rr\c��]!r!r0r0rrr��8Win32ProcessTestCase.test_invalid_args.<locals>.<lambda>�s��Qrr�r�r"s&rr��&Win32ProcessTestCase.test_invalid_args�s1�����*�j�o�o��>�>�4�5�7�%.�	�	0rc���QQ[2oUO[29^tt^2[O[
U2Q5PPP2P!)%fhP!9h)c��\sQsQsPsQsP!)�4Win32ProcessTestCase.test_issue31471.<locals>.BadEnvi�r0)r2r3r4r5�keysr6r0rr�BadEnvr��s���Drr�r�)�dictrkr�rrKr)r#r�s& r�test_issue31471�$Win32ProcessTestCase.test_issue31471�s@��	�T�	�
�
�
�y�
)�
)����_�&�(�;�*�
)�
)�
)�s�"A�A+	�#A+	c�~�[O[OQQ,P	Q5oUO	U]/2P!)rr\)r'r]rbs& rr��#Win32ProcessTestCase.test_close_fds�s5��
�_�_�c�n�n�d�8�:�(,�.��	
����R� rc
� �]PHo[O2oUO[OU]*2UO[OU]*2,oSFD:o[O
UP	2UO
UOU22J<	[O[OQQOU]*2,[OP
Q5oUO2vqgUOUO ]2[#UO%22[O[OQQOU]*2,[O[OP	Q5oUO2vqgUOUO ]2UO'QU2,o[O(2o	QU-U	m[O[OQQOU]*2,[O[OU	P	Q5oUO2vqgUOUO ]2UO'QU2[,O.Q[0129^tt^2[O(2o	QUQ	*-U	m[O[OQQOU]*2,[O[OU	P
Q5oUO2vqgUOUO ]2PPP2P!)%fhP!9h)
rrz2import msvcrt; print(msvcrt.open_osfhandle({}, 0))r�)rIrJr'sOSErrorrw)rIrJr�r'z.*overriding close_fds:NNN)r�rr�r�rPr�r��
get_osfhandlerrKr_r`r�rLr�rarrr�rqrkr|rr�r�)
r#r�r�r�r�rRrIrJrwr�s
&         r�test_close_fds_with_stdio�.Win32ProcessTestCase.test_close_fds_with_stdio�s�����g�g�i��������#�a�&�)�������#�a�&�)����B����r�4�(��N�N�6�/�/��3�4��
���c�n�n�d�R�Y�Y�Za�bc�Zd�e�g�$.�O�O�u�
F��������������q�)��F�L�L�N�����c�n�n�d�R�Y�Y�Za�bc�Zd�e�g�$.�O�O�J�O�O�W[�
]��������������q�)��
�
�j�&�)��� �,�,�.��'4�k�&B��#����c�n�n�d�R�Y�Y�Za�bc�Zd�e�g�$.�O�O�J�O�O�)4��
F��������������q�)��
�
�j�&�)��
+�
+�-E�-;�-=�>�>�$�0�0�2�K�+8�'�!�*�*E�K�'�� � �#�.�.�$�"V�"]�"]�^e�fg�^h�"i�"k�(2���
���-8�E�K�A��]�]�_�N�F����Q�\�\�1�-�>�>�>�>�s�B2M<�<N
	�N
	c�x�[O2o-Um[O[UQ5P!)r��rrkr|r^r�r#r�s& r�test_empty_attribute_list�.Win32ProcessTestCase.test_empty_attribute_list
s)�� �,�,�.��&(��#�����$/�	1rc�|�[O2oQ,-Um[O[UQ5P!)rwr�r�r�s& r�test_empty_handle_list�+Win32ProcessTestCase.test_empty_handle_lists.�� �,�,�.��'4�b�&9��#�����$/�	1rc�B�[OO2oQUQ$[OQ,][O
UQ5oU9^tt^2UO
QUOO22PPP2P!)%fhP!9h��physalisr�r]r�sphysalis�	rr�r�rrKrLrqrIr2r�s&  rr��(Win32ProcessTestCase.test_shell_sequencesf�������"��$��w�����e�W�A�$.�O�O�!'�
)���Q��M�M�+�q�x�x�}�}��7��Q�Q�Q�s�+B
�
B	�B	c�@�[OO2oQUQ$[OQ][O
UQ5oU9^tt^2UO
QUOO22PPP2P!)%fhP!9hr�r�r�s&  rr��&Win32ProcessTestCase.test_shell_string#sd�������"��$��w�����U�!�$.�O�O�!'�
)���Q��M�M�+�q�x�x�}�}��7��Q�Q�Q�s�+B�B	�B	c
�X�QFD�o[OO2oQUQ$[OQ][O
UUQ5oU9^tt^2UO
QUOO2U2PPP2J�	P!)%fhJ�9h)�ansir�r�r])rrIr�r�)r��oemr�)r#�encr�rRs&   r�test_shell_encodings�)Win32ProcessTestCase.test_shell_encodings-sx��"�C��Z�Z�_�_�&�F�(�F�7�O�� � ��a�(2���%+�*-�/�A����
�
�j�!�(�(�-�-�/�3�?���#����s�,B	�B)
�!B)
c��[O[OQ*2oUO	U]/2P!)z -c "import sys; sys.exit(47)"r]rbs& rr��%Win32ProcessTestCase.test_call_string9s.��
�_�_�S�^�^�=�>�?������R� rc���[O[OQQ,[O[O[OQ5oU9^tt^2UO
O
]2[V12UUO2vqEUOUQ2UO2oPPP2UOW]2P!)%fhK$9h)rz�if 1:
                             import sys, time
                             sys.stdout.write('x\n')
                             sys.stdout.flush()
                             time.sleep(30)
                             rGr)rrKr_r`rLrIr2rr�rar)r)r#r�r?rRr�rJrs&&*    rr��"Win32ProcessTestCase._kill_process?s������c�n�n�d�5!�"�$.�?�?�$.�O�O�$.�O�O�
5���Q�
�H�H�M�M�!���A���%��
�
��I�A����V�S�)�����J��	
���J��*��Q�s�!A C�C-	�&C-	c��[O[OQQ,[O[O[OQ5oU9^tt^2UO
O
]2[O]2[V12UUO2vqEUOUQ2UO2oPPP2UOW]*2P!)%fhK$9h)rz�if 1:
                             import sys, time
                             sys.stdout.write('x\n')
                             sys.stdout.flush()
                             sys.exit(42)
                             rGr)
rrKr_r`rLrIr2r:r�rr�rar))r#r�r?rRr�rJrcs&&*    rr��'Win32ProcessTestCase._kill_dead_processTs������c�n�n�d�5!�"�$.�?�?�$.�O�O�$.�O�O�
5���Q�
�H�H�M�M�!���J�J�q�M��A���%��
�
��I�A����V�S�)�����B��	
����R� ��Q�s�!A6C3�3D	�<D	c�H�UOQ[O2P!r�)r�r+r�r"s&rr��%Win32ProcessTestCase.test_send_signalks�����=�&�.�.�9rc�*�UOQ2P!r�r�r"s&rr��Win32ProcessTestCase.test_killns�����6�"rc�*�UOQ2P!rr�r"s&rr��#Win32ProcessTestCase.test_terminateqs�����;�'rc�H�UOQ[O2P!r�)r�r+r�r"s&rr�*Win32ProcessTestCase.test_send_signal_deadts�����
�v�~�~�>rc�*�UOQ2P!rrr"s&rr�#Win32ProcessTestCase.test_kill_deadws������'rc�*�UOQ2P!rrr"s&rr	�(Win32ProcessTestCase.test_terminate_deadzs������,rr0)r2r3r4r5rprtr~rrer�r�rdr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr	r6r7r8s@rriri{s�����
1�1� O�8
���u�%� �&� �0�
���<��<�!�0.�d1�1�8�8�
@�!�+�*!�.:�#�(�?�(�-�-rric��`�\sQsQsnQQ\O
2s\OO\O
Q2Q2s
QsQsQs
Q	sQ
sQsUsP!)�	MiscTestsi}c�<``�\sQsQsnQs,sU1QksQsUsU9s	!)�MiscTests.RecordingPopeniz<A Popen that saves a reference to each instance for testing.c�b:�[RU_U-U@UOOU2P!r )r�r��instances_createdr�)r#r?r@r�s&*,�rr��!MiscTests.RecordingPopen.__init__�s)����G��d�-�f�-��"�"�)�)�$�/rr0)
r2r3r4r5rCr�r�r6r7rfrgs@@r�RecordingPopenr�s����J���	0�	0rr��_communicatec���[Um[OO	[
OQ29^tt^2o[Um[OO	[
QUO29^tt^2UO[29^tt^2U[OQQ,1Q[
O-U@PPP2PPP2UOQ*FD8oUOU[OPQ5QUO02J:	,oUOFD2oU[OQ	Q56XfJ!UOU2J4	UO!UO"]UOQ
5UO%['U2]UOQ
5PPP2UOO(O+2oUO-2UO/2UO%,UOO(2P!)%fhCKq9h)%fhCK}9h)%fhK�9hSOO(O+2oSO-2SO/2SO%,SOO(2h9h)a_Fake a SIGINT happening during Popen._communicate() and ._wait().

This avoids the need to actually try and get test environments to send
and receive signals reliably across platforms.  The net effect of a ^C
happening during a blocking subprocess execution which we want to clean
up from is a KeyboardInterrupt coming out of communicate() or wait().
�_waitrKrzLimport time
time.sleep(9)
import sys
sys.stderr.write('\n!runaway child!\n')rIrwriz.no open-ended wait() after the first allowed: g�?r)�KeyboardInterruptr�rrrrrKr�rkr_r`r��call_args_listrr^r��assertLessEqual�
call_countrarr�r�r�r))r#�popener�mock__communicater@�
mock__waitr^�sigint_callsr/s&&&,    r�_test_keyboardinterrupt_no_kill�)MiscTests._test_keyboardinterrupt_no_kill�sD��):��%�	H����"�"�:�#3�#3�W�=�=��*;�
�&��Z�Z�&�&�z�7�'+�':�':�<�<��*�*�+<�=�=������"M�!N�E�(2�'9�'9�E�>D�E�>�<�'�5�5�b�9�9�D��'�'� �$�)�)�D�"9�L�)�8�8�9�;�<�:�
 "��&�5�5�D��t�y�y��6�6�$�+�+�D�1�6��$�$�Z�%:�%:�A�)3�)B�)B�%�D�� � ��\�!2�A�%/�%>�%>�!�@�->�4�)�)�;�;�?�?�A�G��L�L�N��L�L�N����R��!4�!4�!F�!F�G�/>�=�=��<�<�<��	>�=��4�)�)�;�;�?�?�A�G��L�L�N��L�L�N����R��!4�!4�!F�!F�G�so�6I4�AI!�I
	�%,H9
�I
	�BI!�!A$I!�I4�9I
�I
�	I
	�
I
�I
�	I!�!I1	�*I1	�,I4�4A,K c�J�UO[OQQ5P!�gT㥛� @ri)r�rr^r"s&r�#test_call_keyboardinterrupt_no_kill�-MiscTests.test_call_keyboardinterrupt_no_kill�s���,�,�Z�_�_�e�,�Lrc�J�UO[OQQ5P!r�)r�rrr"s&r�"test_run_keyboardinterrupt_no_kill�,MiscTests.test_run_keyboardinterrupt_no_kill�s���,�,�Z�^�^�U�,�Krc�0�QoUOU2P!)c�x�[OU-U@9^tt^2o[g)%fhP!9hr )rrKr�)r?r@�unused_processs*, r�popen_via_context_manager�[MiscTests.test_context_manager_keyboardinterrupt_no_kill.<locals>.popen_via_context_manager�s,���!�!�4�2�6�2�2�n�'�'�3�2�2�s�(�9	�9	)r�)r#r�s& r�.test_context_manager_keyboardinterrupt_no_kill�8MiscTests.test_context_manager_keyboardinterrupt_no_kill�s��	(�	
�,�,�-F�Grc��UO[OQ2Q2UO[OQ2Q2Po[O
2o[OOUQ2o[O[%cQLQU*2vq4UOU]2Ud[OU2P!P!Sd[OS2hh9h)z
echo xyzzy�xyzzyr�ztype zcat )rr�)rar�	getoutput�getstatusoutputr�r�rrrr'r�rmdir)r#�dirrmr4r�s&    r�test_getoutput�MiscTests.test_getoutput�s�������-�-�l�;�W�E�����3�3�L�A�%�	'���	��"�"�$�C��7�7�<�<��U�+�D�'�7�7�%�I��6�T�9�;�N�F������*�������
���s������
��s�AC#�"#C#�#D�(Dc�n�.Qlo[[O2o[2o]PHo[OO2FDMvqVUO
Q2%cJ[VdO12%cJ<UOU2JO	UOV#U*
2P!)z*Ensure that __all__ is populated properly.r�>r�r+r��Handler�)r]r�__all__rH�__dict__�itemsr�r.�
ModuleTyper�ra)r#�intentionally_excluded�exported�possible_exportsrHrmrps&      r�test__all__�MiscTests.test__all__�s���!R���z�)�)�*���5���%�.�.�4�4�6�K�D����s�#�#���%�"2�"2�!4�5�5��� � ��&�7�	
����6L�#L�Mrr0)r2r3r4r5rrKr�rrrr�r�r�r�r�r�r6r7r8s@rr�r�}sh����0��)�)�0�
�Z�Z���z�'�'��8�)H�9�)H�VM�L�H��&N�Nrr��PollSelectorz!Test needs selectors.PollSelectorc�.`�\sQsQsnQsQsQsUsP!)�ProcessTestCaseNoPolli�c��[OUm[O[m[
O
U2P!r )r�_PopenSelector�
orig_selector�	selectors�SelectSelectorrEr$r"s&rr$�ProcessTestCaseNoPoll.setUp�s,��'�6�6���$-�$<�$<�
�!����d�#rc�\�UO[m[O	U2P!r )r�rr�rEr.r"s&rr.�ProcessTestCaseNoPoll.tearDown�s��$(�$6�$6�
�!�� � ��&r)r�r1r8s@rr�r��s����$�
'�'rr�zWindows-specific testsc�^``�\sQsQsnU1QksU1QksQsQsQsQs	Qs
Q	sUsU9s
!)
�CommandsWithSpacesi�c��:�[RU_2[OQQ2vqUO	2Um[OUQ2[OU2P!)z.pyzte stsVimport sys;sys.stdout.write('%d %s' % (len(sys.argv), [a.lower () for a in sys.argv])))	r�r$r�rrxr�rr�rP)r#rSr�r�s&  �rr$�CommandsWithSpaces.setUp�sN���
��
���#�#�E�7�3����[�[�^��
�
����c�	
�	����rc�f:�[OUO2[RU_2P!r )rrr�r�r.r�s&�rr.�CommandsWithSpaces.tearDown�s���
�	�	�$�*�*��
���rc�>�[OUQ$[OU-U@oU9^tt^2UOUOO2O
Q2QUO*2PPP2P!)%fhP!9h)rI�mbcsz2 [%r, 'ab cd'])rrLrKrarIr2r3r�)r#r?r@rRs&*, r�with_spaces�CommandsWithSpaces.with_spaces�si��%�?�?��x�����d�-�f�-��
�Q�����h�h�m�m��%�%�f�-��$�*�*�,�
��Q�Q�Q�s�AB�B	�B	c	�x�UOQ[O8QUO8QQ8Q0]Q5P!)�"�" "�ab cdr�r
r_r`r�r"s&r�test_shell_string_with_spaces�0CommandsWithSpaces.test_shell_string_with_spacess-�����S�^�^�T�Z�Z�-4�6�=>�	�	@rc�d�UO[OUOQ,]Q5P!)rrrr"s&r�test_shell_sequence_with_spaces�2CommandsWithSpaces.test_shell_sequence_with_spacess$�����#�.�.�$�*�*�g�>�a��Hrc	�t�UOQ[O8QUO8QQ8Q02P!)r
rrrr"s&r�test_noshell_string_with_spaces�2CommandsWithSpaces.test_noshell_string_with_spacess$�����S�^�^�T�Z�Z�$�&�	'rc�`�UO[OUOQ,2P!)rrr"s&r�!test_noshell_sequence_with_spaces�4CommandsWithSpaces.test_noshell_sequence_with_spacess�����#�.�.�$�*�*�g�>�?r)r�)r2r3r4r5r$r.r
rrrrr6r7rfrgs@@rrr�s1�������@�
I�'�
@�@rrc�@`�\sQsQsnQsQsQsQsQsQs	Us
P!)�ContextManagerTestsic��[O[OQQ,[O[OQ59^tt^2oUOUOO2Q2UOUOO2Q2PPP2UOWOO2UOUOO2P!)%fhK\9h)rzAimport sys;sys.stdout.write('stdout');sys.stderr.write('stderr');r�sstdoutsstderr)rrKr_r`rLrarIr2rJrPrQrDs& r�	test_pipe�ContextManagerTests.test_pipes���
�
�
�s�~�~�t� =�>�&0�_�_�%/�_�_�6�6�
:>����T�[�[�-�-�/��;����T�[�[�-�-�/��;�6�	
������*�*�+�������*�*�+�6�6�s�AC9�9D		�D		c���[O[OQQ,29^tt^2oPPP2UO	WO
]d2P!)%fhK.9h)rzimport sys; sys.exit(100))rrKr_r`rarrDs& rrr�#ContextManagerTests.test_returncode)sQ��
�
�
�s�~�~�t�:�<�=�=�@D��=�	
������#�.�	=�=�s�A�A)	�"A)	c��[O[OQQ,[OQ59^tt^2oUOQ2UO
UO]2PPP2P!)%fhP!9h)rz2import sys;sys.exit(sys.stdin.read() == 'context')r�scontextr�rDs& rr��*ContextManagerTests.test_communicate_stdin0sn��
�
�
�s�~�~�t�H�I�$.�?�?�4�4�8<����Z�(����T�_�_�a�0�4�4�4�4�s�.A9�9B
	�B
	c	�8�UO[29^tt^2[O[[O
[O
Q59^tt^2oPPP2PPP2P!)%fhK9h)%fhP!9h)r�)rkrrrKrrLrDs& rr��%ContextManagerTests.test_invalid_args8sa��
�
�
�1�
2�
2��!�!�/�)3���)3���:�:�=A��:�3�
2�:�:��3�
2�
2�s0�AB�!A5	�#B�5B
�>B
�B�B	�B	c��[O[[O[O
]*Q5oUO
2oUOOQ[O
*2UOUO2UO[UOPPP2UOUO]2UOUOO 2P!)z9Broken pipe error should not prevent wait() (Issue 21619))rHrVr.)rrKrrLrr]�	__enter__rHr�rrrkr��__exit__rarPrQrDs& r�test_broken_pipe_cleanup�,ContextManagerTests.test_broken_pipe_cleanup?s�������&0�o�o�(/�(=�(=�a�(?�A���~�~���	
�
�
����� 5� 5�5�6����$�/�/�*����'�4�=�=�$��d�C�������!�,�����
�
�)�)�*rr0)r2r3r4r5rrrr�r�r*r6r7r8s@rrrs#����,�/�1��+�+rrc�`�\sQsQsnQs\Os\Os	\
OQQ,sQs
Qs\O \%(QQ5Q	2s\O \	%(Q
Q5Q2s\O \	%(Q
Q5Q2sQ
s\O \%(QQ5Q2s\O \	%(Q
Q5Q2sQs\O \%(QQ5Q2s\O \	%(Q
Q5Q2s\O4\9%f\	Q2Q2s\O \Q2Q2s\O \Q2Q2s\O \Q2Q2sQs Us!P!)�FastWaitTestCaseiQzcTests for efficient (pidfd_open() + poll() / kqueue()) process
waiting in subprocess.Popen.wait().
rr�r�c	��[[O[O[O22o[
OVQ59^tt^2o[OUO2oUO[O29^tt^2UOUO2PPP2UOUO[O Q5]2PPP2UO#WO$2P!)%fhKe9h)%fhK@9h)r�ri)r�r�r�rr�rrrrK�COMMANDrkrlr)�WAIT_TIMEOUTrarr�rP�called)r#�patch_pointr��mrRs&&   r�assert_fast_waitpid_error�*FastWaitTestCase.assert_fast_waitpid_errorZs����e�l�l�B�K�K����$=�>��
�Z�Z��
5�
5��� � ����.�A��"�"�:�#<�#<�=�=����t�(�(�)�>����Q�V�V�G�,A�,A�V�B�A�F�	6�
	
������!�>�=��6�
5�s1�AD1�%D	�8D1�D.
�'D.
�)D1�1E	�:E	zneeds pidfd_open())�reasonc�*�UOQ2P!�z
os.pidfd_open�r4r"s&r�test_wait_pidfd_open_error�+FastWaitTestCase.test_wait_pidfd_open_errore����&�&��7rzneeds kqueue() for procc�*�UOQ2P!��
select.kqueuer9r"s&r�test_wait_kqueue_error�'FastWaitTestCase.test_wait_kqueue_errorir<rc	��[OUO2o[O2o[[O[O[O22UOm[O2Um[OQUQ59^tt^2oUO[O29^tt^2UO!UO"2PPP2UO%UO![&O(Q5]2PPP2UO+WO,2P!)%fhKe9h)%fhK@9h)r?rPri)rrKr/r�Mockr�r�rrr��controlr�rPrrkrlr)r0rarr�rPr1)r#rR�kq_mockr3s&   r�test_kqueue_control_error�*FastWaitTestCase.test_kqueue_control_errorms���
���T�\�\�*���)�)�+��&-��K�K����U�[�[�1�'
����#��	�	���
�
�Z�Z��g�
>�
>�!��"�"�:�#<�#<�=�=����t�(�(�)�>����Q�V�V�G�,A�,A�V�B�A�F�?�	
������!�>�=��?�
>�s0�<(E0�$E	�8E0�E-
�&E-
�(E0�0F	�9F	c�j``�[OUO2nUU1Qko[OVQ59^tt^2oRO[OQ5oPPP2UOWO2UOW]2P!)%fhK?9h)c��:�RU-U@o[ORO[O2[O
RO]2U![cS!h9hrw)rr�r9r+r�r�r�)r?r@�retrR�	real_funcs*, ��r�wrapper�<FastWaitTestCase.assert_wait_race_condition.<locals>.wrapper�s_����T�,�V�,�C�
�������v�~�~�.��
�
�1�5�5�!�$��J���
���J�
�s�AA�	A.�)A.�-A.r�ri)rrKr/rrr)rr�rPr1ra)r#�patch_targetrKrLr3r4rRs&&f   @r�assert_wait_race_condition�+FastWaitTestCase.assert_wait_race_condition~su���
���T�\�\�*��	��Z�Z��
:�
:�a��V�V�G�$9�$9�V�:�F�;�������!������#�;�
:�s�
!B"�"B2	�+B2	c�H�UOQ[O2P!r8)rOr�
pidfd_openr"s&r�test_pidfd_open_race�%FastWaitTestCase.test_pidfd_open_race�s���'�'�����Grc�H�UOQ[O2P!r>)rOr�kqueuer"s&r�test_kqueue_race�!FastWaitTestCase.test_kqueue_race�s���'�'�����Grc�&``�UU1Qko]n[On[OO	[
OUP	Q59^tt^2o[OQUQ59^tt^2o[
OUO2oUO[
O29^tt^2UOUO2PPP2UOUO[OQ5]2PPP2PPP2UOWO 2UOWO 2P!)%fhK�9h)%fhKc9h)%fhKn9h)c�::�R]*
nR]6XcQ!RV2!)r�)rrr0)r9�flags�ncalls�real_waitpids&&��r�waitpid_wrapper�TFastWaitTestCase.assert_notification_without_immediate_reap.<locals>.waitpid_wrapper�s#����a�K�F���{��
���+�+rrPz
os.waitpidr�ri)rr�rrrrrKr/rkrlr)r0rarr�rPr1)r#rNr^�m1�m2rRr\r]s&&    @@r�*assert_notification_without_immediate_reap�;FastWaitTestCase.assert_notification_without_immediate_reap�s���	,����z�z��
�Z�Z�
�
�z�/�/��D�
�
Q�
Q�UW����L�o�F�F�"��$�$�T�\�\�2���&�&�z�'@�'@�A�A��F�F�4�,�,�-�B�� � �����0E�0E��!F��J�	G�R�	
����	�	�"�����	�	�"�	B�A��G�F��R�
Q�sO�!F�6AE-	�>E
�8E-	�F�E*�#E*�%E-	�-E=
�6E=
�8F�F	�	F	c�*�UOQ2P!)�_wait_pidfd�rbr"s&r�3test_pidfd_open_notification_without_immediate_reap�DFastWaitTestCase.test_pidfd_open_notification_without_immediate_reap�s���7�7�
�Frc�*�UOQ2P!)�_wait_kqueuerfr"s&r�/test_kqueue_notification_without_immediate_reap�@FastWaitTestCase.test_kqueue_notification_without_immediate_reap�s���7�7��Grz!fast wait mechanism not availablec	��[OQ29^tt^2o[OUO2oUO[O29^tt^2UOUO2PPP2UOUO[OQ5]2PPP2UOWO2P!)%fhKe9h)%fhK@9h)z
time.sleepri)rrrrKr/rkrlr)r0rarrKr+r1)r#r3rRs&  r�test_fast_path_avoid_busy_loop�/FastWaitTestCase.test_fast_path_avoid_busy_loop�s����Z�Z��
%�
%��� � ����.�A��"�"�:�#<�#<�=�=����t�(�(�)�>����Q�V�V�G�,@�,@�V�A�1�E�	&�
	
������"�>�=��&�
%�s0�AC4�(C!	�8C4�!C1
�*C1
�,C4�4D	�=D	z&requires the POSIX wait implementationc
�6�Q[O[Q21FDboUOUQ59^tt^2[O
[2oUOUOUQ5]2PPP2Jd	P!)%fhJy9h)�
�infrild(	)	r_�maxsize�floatr-rrKrrar))r#rjrRs&  r�test_wait_huge_timeout�'FastWaitTestCase.test_wait_huge_timeout�sk��
����U�5�\�:�G����g��.�.��$�$�_�5��� � ������!8�!�<�/�.�;�.�.�.�s�=B	�B
�B
c�x�[O[QQ5oUOUO]2P!)g _�Brirxrps& r�test_run_huge_timeout�&FastWaitTestCase.test_run_huge_timeout�s(���^�^�O�T�
:���������*rc�<�[OO[QQ29^tt^2[OUO
2oUO
UO[OQ5]2PPP2P!)%fhP!9h)�_MAXIMUM_WAIT_TIMEOUTg{�G�z�?ri)
rrrrrKr/rar)rr�rQs& r�$test_wait_slices_do_not_expire_early�5FastWaitTestCase.test_wait_slices_do_not_expire_early�sc��
�Z�Z�
�
�z�+B�D�
I�
I�� � ����.�A����Q�V�V�G�,A�,A�V�B�A�F�J�
I�
I�
I�s�AB
�
B	�B	r0)"r2r3r4r5rCr�_CAN_USE_PIDFD_OPEN�CAN_USE_PIDFD_OPEN�_CAN_USE_KQUEUE�CAN_USE_KQUEUEr_r`r/r0r4r�r]r:r@rFrOrSrWrbrgrkrbrnr'rurxr|r6r7r8s@rr-r-Qs������$�7�7���/�/�N��~�~�t�%C�D�G��L�	"��_�_�+�+�4H�I�8�J�8��_�_��'�0I�J�8�K�8��_�_��'�0I�J�"�K�"� $�(�_�_�+�+�4H�I�H�J�H��_�_��'�0I�J�H�K�H�#�*�_�_�+�+�4H�I�G�J�G��_�_��'�0I�J�H�K�H�����,�,�n�+��#�	�#��_�_�Y� H�I�=�J�=��_�_�Y� H�I�+�J�+��_�_�Y� H�I�G�J�Grr-�__main__)�nonexisting_i_hope)Kr�rrkr�test.supportrrrrr�test.support.script_helperr	rr_r+rNr]rr�r�r:r�rHr�r`rrr2r�r�rvr[�test.support.os_helperr
r3r�r+r�r�r��PGOr��has_subprocess_supportr�r'rkrrJ�NotADirectoryErrorrrr`rr�TestCaser�	Exceptionr;rKr=rErhr�r]r�rbrir�rcr�rrr-r2�mainr0rr�<module>r�s������(�&�"�&�(�7��
�
�	��	��������
�
�
��	���+������������;�;�;�
�
�
�9�
:�:��%�%�%�
�
�
�=�
>�>�
�\�\�W�
$�	�
�@�I��I�)��'�);�_�M���>�>�4��0��(� �8�$�$� �&	��	�>�j�.�.�>�O+�l�O+�d6@J�l�@J�F	c�
����2�3�]Q�<�]Q�4�]Q�@3
���Y� 8�9�-�<�-�:�-�BaN��!�!�aN�H
���W�Y��7�8�:�'�O�'�:�'�
���Y� 8�9�(@�,�(@�:�(@�V3+�,�3+�nLG�|�LG�\�z���M�M�O���{E���I���
��
�C�����
�C������H���
��E�sl�
I�I�I"�I2�!J�I�I�I�I�I�I�"I/�(I/�.I/�2I?�8I?�>I?�J	

Youez - 2016 - github.com/yon3zu
LinuXploit