o
    ҷh0                     @   s  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mZ ddl	m
Z
mZ ddlmZ ejdkr6ejdks:er:J zd d	lmZ d
eddfddZW n% eyp   d dlZe Zed edjZd
eddfddZY nw e
ejZd
ededdfddZdddZdS )    N)TYPE_CHECKING   )_core_subprocess)CapacityLimiterEvent)to_thread_run_syncwin32darwin)waitidpidreturnc                 C   s   t tj| tjtjB  d S N)r   osP_PIDWEXITEDWNOWAIT)r    r   S/var/www/html/venv/lib/python3.10/site-packages/trio/_subprocess_platform/waitid.pysync_wait_reapable   s   r   z
typedef struct siginfo_s {
    int si_signo;
    int si_errno;
    int si_code;
    int si_pid;
    int si_uid;
    int si_status;
    int pad[26];
} siginfo_t;
int waitid(int idtype, int id, siginfo_t* result, int options);
c                 C   sb   d}d}t jdkrd}nd}td}t|| |||B dk r/tj}|tjkr'qt|t	|d S )N      r
       i   zsiginfo_t *r   )
sysplatform
waitid_ffinewwaitid_cffierrnoEINTROSErrorr   strerror)r   r   r   r   result	got_errnor   r   r   r   /   s   


eventc                    sX   z%zt t| dtdI dH  W n	 ty   Y nw W |  dS W |  dS |  w )zdSpawn a thread that waits for ``pid`` to exit, then wake any tasks
    that were waiting on it.
    T)abandon_on_cancellimiterN)r   r   waitid_limiterr    set)r   r$   r   r   r   _waitid_system_taskG   s   	r)   process_subprocess.Processc                    sL   | j d u rt  | _ }tt| j| t| j tsJ | j  I d H  d S r   )_wait_for_exit_datar   r   spawn_system_taskr)   r   
isinstancewait)r*   r$   r   r   r   wait_child_exitingb   s   
r0   )r*   r+   r   N)r   mathr   r   typingr    r   r   _syncr   r   _threadsr   r   r   intr   ImportErrorcffiFFIr   cdefdlopenr   infr'   r)   r0   r   r   r   r   <module>   s0    
1