Your IP : 3.129.253.21


Current Path : /usr/lib64/python3.6/site-packages/psutil/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/psutil/__pycache__/_psposix.cpython-36.pyc

3

��JZ��@s�dZddlZddlZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZddl
mZdd	l
mZd
ddd
gZdd
�Zddd�Zdd�Zedd
��ZdS)z%Routines common to all posix systems.�N�)�memoize)�
sdiskusage)�
usage_percent)�PY3)�unicode)�TimeoutExpired�
pid_exists�wait_pid�
disk_usage�get_terminal_mapcCsl|dkrdSytj|d�WnFtk
rb}z*|jtjkr>dS|jtjkrNdS|�WYdd}~XnXdSdS)z6Check whether pid exists in the current process table.rTFN)�os�kill�OSError�errnoZESRCHZEPERM)�pid�err�r� /usr/lib64/python3.6/_psposix.pyr	sc	s�����fdd�}ttdtj���dk	rB�fdd�}����n�fdd�}d}x�y|�\}}Wnftk
r�}zJ|jtjkr�||�}wTn,|jtjkr�xt��r�||�}q�dSq�Wn�WYdd}~XqTX|d	kr�||�}qTtj|�r�tj	|�Stj
|��rtj|�Std
|��qTWdS)aIWait for process with pid 'pid' to terminate and return its
    exit status code as an integer.

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

    If pid does not exist at all return None immediately.

    Raise TimeoutExpired on timeout expired.
    cs8�dk	r ���kr t���d��tj|�t|dd�S)N)r�name�g{�G�z�?)r�timeZsleep�min)�delay)r�	proc_name�stop_at�timeout�timerrr�
check_timeout?s


zwait_pid.<locals>.check_timeoutZ	monotonicNcstj�tj�S)N)r
�waitpid�WNOHANGr)rrr�waitcallHszwait_pid.<locals>.waitcallcstj�d�S)Nr)r
rr)rrrr!Lsg-C��6?rzunknown process exit status %r)
�getattrrrrZEINTRZECHILDr	r
�WIFSIGNALED�WTERMSIG�	WIFEXITED�WEXITSTATUS�
ValueError)	rrrrr!rZretpidZstatusrr)rrrrrrr
4s8



cCs�trtj|�}ndytj|�}WnTtk
rrt|t�rly|jtj��}Wntk
r^YnXtj|�}n�YnX|j	|j
}|j|j
}|j|j
}||}||}t
||dd�}t||||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)Z_round)�total�usedZfreeZpercent)rr
�statvfs�UnicodeEncodeError�
isinstancer�encode�sys�getfilesystemencoding�f_blocks�f_frsize�f_bfree�f_bavailrr)�path�str(Z
avail_to_rootZ
avail_to_userr)Z
total_userZusage_percent_userrrrrws(
cCs�i}tjd�tjd�}xb|D]Z}||ks2t|��y||tj|�j<Wqtk
rv}z|jtjkrf�WYdd}~XqXqW|S)zMGet a map of device-id -> path as a dict.
    Used by Process.terminal()
    z	/dev/tty*z
/dev/pts/*N)�glob�AssertionErrorr
�stat�st_rdevrr�ENOENT)�retZlsrrrrrr�s
)NN)�__doc__rr6r
r.rZ_commonrrrZ_compatrr�_exceptionsr�__all__r	r
rrrrrr�<module>s 
C1

?>