HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/psutil/__pycache__/_psposix.cpython-310.pyc
o

;j7-�@sNdZddlZddlZddlZddlZddlZddlZddlZddlm	Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZerJdd
lmZgd�Zdd
�Ze�ddd�ejD��Zdd�Zdd�Zdejeedej�eejefdd�Zdd�Zd(dd�Zd(dd�Z edd��Z!ed d!��Z"d(d"d#�Z#eje#_d$d%�Z$ed&d'��Z%dS))z%Routines common to all posix systems.�N�)�_ntuples)�MACOS��TimeoutExpired)�debug)�memoize)�
usage_percent)�_psutil_osx)�
pid_exists�wait_pid�
disk_usage�get_terminal_mapcCsF|dkrdSz	t�|d�WdStyYdSty"YdSw)z6Check whether pid exists in the current process table.rTF)�os�kill�ProcessLookupError�PermissionError)�pid�r�C/opt/saltstack/salt/lib/python3.10/site-packages/psutil/_psposix.pyrs	��r�	NegsignalcCsi|]}|j|j�qSr)�name�value��.0�xrrr�
<dictcomp>4srcCs"zt|�WSty|YSw)z+Convert a negative signal value to an enum.)r�
ValueError)�numrrr�negsig_to_enum8s

�rcCs@t�|�r
t�|�St�|�rtt�|��Sd|��}t|��)z.Convert a os.waitpid() status to an exit code.zunknown process exit status )r�	WIFEXITED�WEXITSTATUS�WIFSIGNALEDr�WTERMSIGr)�status�msgrrr�convert_exit_code@s



r&�	monotoniccs�d}d�d}d��dur|tjO}�dkr����������fdd�}		z
t�||�\}
}WntyF||�rC|	|�}||�s;YdSw|
dkrP|	|�}nt|�Sq&)a�Wait for a process PID to terminate.

    If the process terminated normally by calling exit(3) or _exit(2),
    or by returning from main(), the return value is the positive integer
    passed to *exit().

    If it was terminated by a signal it returns the negated value of the
    signal which caused the termination (e.g. -SIGTERM).

    If PID is not a children of os.getpid() (current process) just
    wait until the process disappears and return None.

    If PID does not exist at all return None immediately.

    If timeout is specified and process is still alive raise
    TimeoutExpired.

    If timeout=0 either return immediately or raise TimeoutExpired
    (non-blocking).
    g-C��6?g{�G�z�?rNcs8�dks
�dur���krt����|��|d��S)Nr�r)�interval��_min�_sleep�_timerZmax_intervalZstop_at�timeoutrr�sleep_or_timeout�sz(wait_pid_posix.<locals>.sleep_or_timeout)r�WNOHANG�waitpid�ChildProcessErrorr&)rr.�_waitpidr-r+r,Z_pid_existsr)�flagsr/�retpidr$rr*r�wait_pid_posix_s,

��
�r6cCsFz
t�|d�\}}Wntyt||�YSw|dksJ�t|�S)zhWrapper around os.waitpid(). PID is supposed to be gone already,
    it just returns the exit code.
    r)rr1r2r6r&)rr.r5r$rrrr3�s�r3c
Cs�zt�|d�}Wn<tyD}z0|jtjkr!t||�WYd}~S|jtjtjtjhvr?t	d|�d��t||�WYd}~S�d}~wwz-t
��}|�|t
j
�|durWdnt|d�}|�|�}|sht|��t||�Wt�|�St�|�w)zbWait for PID to terminate using pidfd_open() + poll(). Linux >=
    5.3 + Python >= 3.9 only.
    rNzpidfd_open() failed (�); use fallbacki�)r�
pidfd_open�OSError�errno�ESRCHr6�EMFILE�ENFILEZENODEVr�select�poll�register�POLLIN�intrr3�close)rr.�pidfd�errZpollerZ
timeout_ms�eventsrrr�wait_pid_pidfd_open�s(��

rGc
Cs zt��}Wn)ty/}z|jtjtjhvr*td|�d��t||�WYd}~S�d}~wwzZtj|tj	tj
tjBtjd�}z
|�
|gd|�}Wn0tyz}z$|jtjtjtjhvrutd|�d��t||�WYd}~W|��S�d}~ww|s�t|��t||�W|��S|��w)z=Wait for PID to terminate using kqueue(). macOS and BSD only.zkqueue() failed (r7N��filterr4Zfflagsrzkqueue.control() failed ()r>�kqueuer9r:r<r=rr6�kevent�KQ_FILTER_PROC�	KQ_EV_ADD�
KQ_EV_ONESHOT�KQ_NOTE_EXIT�controlZEACCES�EPERMr;rCrr3)rr.�kqrE�kevrFrrr�wait_pid_kqueue�s<��
�
���
rTc
Csxttd�sdSz
t�t��d�}Wn#ty4}z|jtjtjhvr)WYd}~dSWYd}~dSd}~wwt�|�dS)Nr8FrT)	�hasattrrr8�getpidr9r:r<r=rC)rDrErrr�can_use_pidfd_open�s
��
rWc
Cs�d}tdd�|D��s
dSd}zez+t��}tjt��tjtjtjBtj	d�}|�
|gdd�WW|dur:|��dSdStyt}z-|j
t
jt
jhvr^WYd}~W|dur\|��dSdSWYd}~W|durn|��dSdSd}~ww|dur~|��ww)	N)rJrMrNrLrOcss�|]}tt|�VqdS�N)rUr>rrrr�	<genexpr>s�z!can_use_kqueue.<locals>.<genexpr>FrHrrT)�allr>rJrKrrVrLrMrNrOrPrCr9r:r<r=)�namesrRrSrErrr�can_use_kqueues@
��������
�r\cCsJ|dksJ�|dur|dksJ�t�rt||�St�r t||�St||�S)Nr)rWrGr\rTr6)rr.rrrr(s


rcCsnt�|�}|j|j}|j|j}|j|j}||}tr#t�||�}||}t	||dd�}t
j||||d�S)a.Return disk usage associated with path.
    Note: UNIX usually reserves 5% disk space which is not accessible
    by user. In this function "total" and "used" values reflect the
    total and used disk space whereas "free" and "percent" represent
    the "free" and "used percent" user disk space.
    r)Zround_)�total�used�free�percent)r�statvfs�f_blocks�f_frsize�f_bfree�f_bavailrr
Zdisk_usage_usedr	�ntpZ
sdiskusage)�path�str]Z
avail_to_rootZ
avail_to_userr^Z
total_userZusage_percent_userrrrr
:s
�r
c	Cs\i}t�d�t�d�}|D]}||vsJ|��z
||t�|�j<Wqty+Yqw|S)zNGet a map of device-id -> path as a dict.
    Used by Process.terminal().
    z	/dev/tty*z
/dev/pts/*)�globr�stat�st_rdev�FileNotFoundError)�retZlsrrrrr^s�rrX)&�__doc__�enumr:rirr>�signal�time�rrfZ_commonrrrrr	r
�__all__r�IntEnum�Signalsrrr&r1�getattr�min�sleepr6r3rGrTrWr\rr
rrrrr�<module>sT�!
�D

# 


 $