HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/env/lib/python3.10/site-packages/billiard/__pycache__/_win.cpython-310.pyc
o

!weg�@s�dZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZddlm
Z
mZdZed�jZGdd�de�Zee�Zdd
d�Zddd
�Zddd�Zddd�Zdd�Zddd�Zdd�ZdS)zZ
    billiard._win
    ~~~~~~~~~~~~~

    Windows utilities to terminate process groups.

�N)	�byref�sizeof�windll�	Structure�WinError�POINTER�c_size_t�c_char�c_void_p)�DWORD�LONG����c@sPeZdZdefdefdefdefdefdefdefdefd	efd
edfg
ZdS)
�PROCESSENTRY32�dwSize�cntUsage�
th32ProcessID�th32DefaultHeapID�th32ModuleID�
cntThreads�th32ParentProcessID�pcPriClassBase�dwFlags�	szExeFileiN)�__name__�
__module__�__qualname__rrrr	�_fields_�rr�F/home/arjun/projects/env/lib/python3.10/site-packages/billiard/_win.pyrs
�r�cCs tj�||�}|tkrt��|S�N)r�kernel32�CreateToolhelp32Snapshot�INVALID_HANDLE_VALUEr)rr�	hSnapshotrrrr#+s�r#cC�ttjj||�Sr!)�_Process32nrr"�Process32First�r%�perrrr(3�r(cCr&r!)r'rr"�
Process32Nextr)rrrr,7r+r,cCsF|durt�}tt�|_||t|��}|s!tj��tkrdSt��|Sr!)	rrrrrr"�GetLastError�ERROR_NO_MORE_FILESr)�funr%r*�successrrrr';s
r'cCs:t�}i}t|�}|r|jr|j||j<t||�}|s|S)z}Return a dictionary with all processes pids as keys and their
       parents as value. Ignore processes with no parents.
    )r#r(rrr,)�h�parentsr*rrr�get_all_processes_pidsGs
�r3TcCslt�}t|���}|h}	|��}|D]
}|||vr |�|�q||kr&n|��}q
|s2|�|�t|�S)z1Return a list with all the pids of a process tree)r3�list�keys�copy�add�remove)�pid�include_parentr2�all_pids�pids�pids_new�_pidrrr�get_processtree_pidsVs 
��
r?cCs"t|�}|D]}t�||�qdS)z&Kill a process and all its descendantsN)r?�os�kill)r9�signum�family_pidsr>rrr�kill_processtreems�rD)r rr!)T)�__doc__r@�ctypesrrrrrrrr	r
�ctypes.wintypesrrr.�valuer$r�LPPROCESSENTRY32r#r(r,r'r3r?rDrrrr�<module>s,