File: //opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyc
�
���Rc           @   s�   d  Z  d d l Z d d l Z 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 m Z d �  Z
 d d � Z d �  Z e d �  � Z d S(	   s%   Routines common to all posix systems.i����N(   t   TimeoutExpired(   t   nt_diskinfot
   usage_percentt   memoizec         C   s]   |  d k  r t  Sy t j |  d � Wn. t k
 rT t j �  d } | j t j k SXt Sd S(   s6   Check whether pid exists in the current process table.i    i   N(	   t   Falset   ost   killt   OSErrort   syst   exc_infot   errnot   EPERMt   True(   t   pidt   e(    (    sB   /opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyt
   pid_exists   s    
c            sq  �  � � � f d �  } t  t d t j � � � d k	 rX �  f d �  } � �  � � n �  f d �  } d } x� y | �  \ } } Wn� t k
 rt j �  d } | j t j k r� | | � } qp qj| j t j k rx( t	 �  � r� | | � } q� d Sq� qj�  qp X| d k r&| | � } qp n  t
 j | � rBt
 j | � St
 j
 | � r^t
 j | � St d	 � � qp d S(
   sI  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            sK   � d  k	 r- � �  � k r- t �  � � q- n  t j |  � t |  d d � S(   Ni   g{�G�z�?(   t   NoneR    t   timet   sleept   min(   t   delay(   R
   t   stop_att   timeoutt   timer(    sB   /opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyt
   check_timeout*   s
    
t	   monotonicc              s   t  j �  t  j � S(   N(   R   t   waitpidt   WNOHANG(    (   R
   (    sB   /opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyt   <lambda>3   s    c              s   t  j �  d � S(   Ni    (   R   R   (    (   R
   (    sB   /opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyR   6   s    g-C��6?i   Ni    s   unknown process exit status(   t   getattrR   R   R   R   R	   R
   t   EINTRt   ECHILDR   R   t   WIFSIGNALEDt   WTERMSIGt	   WIFEXITEDt   WEXITSTATUSt   RuntimeError(   R
   R   R   t   waitcallR   t   retpidt   statust   err(    (   R
   R   R   R   sB   /opt/alt/python27/lib64/python2.7/site-packages/psutil/_psposix.pyt   wait_pid   s:    
c         C   sn   t  j |  � } | j | j } | j | j } | j | j | j } t | | d d �} t | | | | � S(   s'