
    Rh                         d dl Z d dlZddlmZmZ ddlmZ ddlmZ ddlmZ dgZ	 G d d	e
      Z G d
 dej                        Zy)    N   )	reductionset_spawning_popen)
popen_fork)spawn)utilPopenc                       e Zd Zd Zd Zy)_DupFdc                     || _         y Nfdselfr   s     8/usr/lib/python3.12/multiprocessing/popen_spawn_posix.py__init__z_DupFd.__init__   s	        c                     | j                   S r   r   )r   s    r   detachz_DupFd.detach   s    wwr   N)__name__
__module____qualname__r   r    r   r   r   r      s    r   r   c                   2     e Zd ZdZeZ fdZd Zd Z xZ	S )r	   r   c                 2    g | _         t        | 	  |       y r   )_fdssuperr   )r   process_obj	__class__s     r   r   zPopen.__init__   s    	%r   c                 <    | j                   j                  |       |S r   )r   appendr   s     r   duplicate_for_childzPopen.duplicate_for_child"   s    			r   c                    ddl m} |j                         }| j                  j	                  |       t        j                  |j                        }t        j                         }t        |        	 t        j                  ||       t        j                  ||       t        d        d x}x}x}}		 t        j                         \  }}t        j                         \  }}	t        j                  ||      }
| j                  j!                  ||g       t#        j$                  t        j&                         |
| j                        | _        || _        t-        |	dd      5 }|j/                  |j1                                d d d        g }||	fD ]  }||j	                  |        t#        j2                  | t"        j4                  |      | _        ||fD ]  }|t        j8                  |        y # t        d        w xY w# 1 sw Y   xY w# g }||	fD ]  }||j	                  |        t#        j2                  | t"        j4                  |      | _        ||fD ]  }|t        j8                  |        w xY w)Nr   )resource_tracker)
tracker_fdpipe_handlewbF)closefd) r%   getfdr   r"   r   get_preparation_data_nameioBytesIOr   r   dumpospipeget_command_lineextendr   spawnv_passfdsget_executablepidsentinelopenwrite	getbufferFinalize	close_fds	finalizerclose)r   r   r%   r&   	prep_datafpparent_rchild_wchild_rparent_wcmdffds_to_closer   s                 r   _launchzPopen._launch&   s#   &%++-
		$..{/@/@A	ZZ\4 	%NN9b)NN;+t$266676Wx	! "	Hg "	GX((J5<>CIIgw/0**5+?+?+A+.		;DH$DMhe4 ('( L* ,> ''+, "]]4NDN( !>HHRL!+ t$( ( L* ,> ''+, "]]4NDN( !>HHRL!s>   1,G3 1B/H   H H 3H HH I;AI;#I;)
r   r   r   methodr   DupFdr   r#   rI   __classcell__)r    s   @r   r	   r	      s    FE&"!r   )r.   r1   contextr   r   r*   r   r   r   __all__objectr   r	   r   r   r   <module>rP      s<    	 	 2   )V .!J .!r   