
    4\h                     |    d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 dZ
dZdZ G d d	ej                  ZdS )
ar  This test case provides support for checking forking and wait behavior.

To test different wait behavior, override the wait_impl method.

We want fork1() semantics -- only the forking thread survives in the
child after a fork().

On some systems (e.g. Solaris without posix threads) we find that all
active threads survive in the child after a fork(); this is an error.
    N)support)threading_helper   g      ?   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ForkWaitc                 `    t          j                    | _        i | _        d| _        g | _        d S )Nr   )r   threading_setup_threading_keyalivestopthreads)selfs    8/opt/python-3.11.14/usr/lib/python3.11/test/fork_wait.pysetUpzForkWait.setUp   s,    .>@@
	    c                     d| _         | j        D ]}|                                 d }| j                                         t	          j        | j          d S )N   )r   r   joinclearr   threading_cleanupr   )r   threads     r   tearDownzForkWait.tearDown   sY    	l 	 	FKKMMMM*D,?@@@@r   c                     | j         sOt          j                    | j        |<   	 t	          j        t                     n# t          $ r Y nw xY w| j         Md S d S )N)r   osgetpidr   timesleep
SHORTSLEEPOSError)r   ids     r   fz
ForkWait.f'   su    ) 	Y[[DJrN
:&&&&   	 ) 	 	 	 	 	s   > 
A
Ac                2    t          j        ||           d S )Nexitcode)r   wait_process)r   cpidr%   s      r   	wait_implzForkWait.wait_impl/   s    TH555555r   c                    t          t                    D ]L}t          j        | j        |f          }|                                 | j                            |           Mt          j	        t          j
        d          D ]!}t          | j                  t          k    r n"t          | j                                                  }|                     |t!          t          t                                         | j                                        }t$          j        dv rt)          j                    }nt)          j                    }|dk    rWt/          j        t2                     d}| j        D ]}| j        |         ||         k    r|dz  }t)          j        |           d S |                     |d           d S )N)targetargsF)error)	unixware7r   r   r$   )rangeNUM_THREADS	threadingThreadr"   startr   appendr   sleeping_retrySHORT_TIMEOUTlenr   sortedkeysassertEquallistcopysysplatformr   fork1forkr   r   	LONGSLEEP_exitr(   )	r   ir   _aprefork_livesr'   nkeys	            r   	test_waitzForkWait.test_wait2   s   {## 	( 	(A%TV1$???FLLNNNL'''' '(=UKKK 	 	A4:+-- . 4:??$$%%D{!3!344555
))<=((8::DD799D199Jy!!!Az  :c?mC&888FAHQKKKKK NN4!N,,,,,r   N)__name__
__module____qualname__r   r   r"   r(   rH    r   r   r   r      sb          A A A  6 6 6- - - - -r   r   )__doc__r   r<   r   unittestr0   testr   test.supportr   r@   r   r/   TestCaser   rL   r   r   <module>rR      s   	 	                           ) ) ) ) ) ) 	
;- ;- ;- ;- ;-x  ;- ;- ;- ;- ;-r   