| Current Path : /lib/fm-agent/dependencies/psutil/__pycache__/ |
| Current File : //lib/fm-agent/dependencies/psutil/__pycache__/_psposix.cpython-36.pyc |
3
q��i � @ s� d Z ddlZddlZddlZddlZddlZddlmZmZm Z ddl
mZmZ G dd� de
�Zdd� Zdd d
�Zdd� Ze d
d� �ZdS )z%Routines common to all posix systems.� N)�
sdiskusage�
usage_percent�memoize)�PY3�unicodec @ s e Zd ZdS )�TimeoutExpiredN)�__name__�
__module__�__qualname__� r r �1/usr/lib/fm-agent/dependencies/psutil/_psposix.pyr s r c C sj | dkrdS yt j| d� W nD tk
r` tj� d }|jtjkrHdS |jtjkrXdS |�Y nX dS dS )z6Check whether pid exists in the current process table.r T� FN)�os�kill�OSError�sys�exc_info�errno�ESRCH�EPERM)�pid�errr r r �
pid_exists s
r c s ���fdd�}t tdtj���dk r>� fdd�}�� � �n� fdd�}d}x�y|� \}}W nd tk
r� tj� d }|jtjkr�||�}wPn,|jtjkr�xt� �r�||�}q�dS q�W n� Y qPX |d
kr�||�}qPt j
|�r�t j|�S t j|��r t j
|�S td��qPW dS )aI Wait 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.
c s0 �d k r�� � krt � �tj| � t| d d�S )N� g{�G�z�?)r �time�sleep�min)�delay)�stop_at�timeout�timerr r �
check_timeout? s
zwait_pid.<locals>.check_timeout� monotonicNc s t j� t j�S )N)r �waitpid�WNOHANGr )r r r �<lambda>H s zwait_pid.<locals>.<lambda>c s t j� d�S )Nr )r r# r )r r r r% K s g-C��6?r
r zunknown process exit status)�getattrr r r r r ZEINTRZECHILDr r �WIFSIGNALED�WTERMSIG� WIFEXITED�WEXITSTATUS�RuntimeError)r r r! Zwaitcallr Zretpid�statusr r )r r r r r �wait_pid4 s:
r- c C s� yt j| �}W nZ tk
rh t rbt| t�rby| jtj� �} W n tk
rT Y nX t j| �}n� Y nX |j |j
}|j|j
}|j|j |j
}t
||dd�}t||||�S )z'Return disk usage associated with path.r
)�_round)r �statvfs�UnicodeEncodeErrorr �
isinstancer �encoder �getfilesystemencoding�f_bavail�f_frsize�f_blocks�f_bfreer r )�path�st�free�total�used�percentr r r �
disk_usagev s r>