
    ,hc
                         d dl Z d dlZd dlZd dlZddlmZ dZdZ ej                  d      Z	d Z
d Zd	 Zd
 Z G d de      ZddZy)    N   )Process      z
\(.+\)|\S+c            	          t        j                         } dD ]M  }t         j                  j                  t         j                  j	                  dt        |       |            sK|c S  t        d      )zDetect /proc filesystem style.

    This checks the /proc/{pid} directory for possible formats. Returns one of
    the following as str:

    * `stat`: Linux-style, i.e. ``/proc/{pid}/stat``.
    * `status`: BSD-style, i.e. ``/proc/{pid}/status``.
    )statstatus/proczunsupported proc format)osgetpidpathexistsjoinstrProcFormatError)pidnames     X/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/shellingham/posix/proc.pydetect_procr      sV     ))+C" 77>>"'',,wC$?@K 3
44    c                  ~    	 t        j                         j                  j                         dv S # t        $ r Y yw xY w)N)freebsdnetbsd	dragonflyF)r   unamesysnamelower	Exception r   r   _use_bsd_stat_formatr    #   s:    xxz!!'')-OOO s   -0 	<<c                 .   t         j                  j                  dt        |       |      }t	        j
                  |dd      5 }t        j                  |j                               }d d d        t               r	t           S t           S # 1 sw Y   %xY w)Nr
   asciireplaceencodingerrors)r   r   r   r   ioopenSTAT_PATTERNfindallreadr    BSD_STAT_PPIDLINUX_STAT_PPID)r   r   r   fpartss        r   	_get_ppidr0   *   sw    77<<S40D			: /a$$QVVX./ ]##!!/ /s   $BBc                 8   t         j                  j                  dt        |       d      }t	        j
                         xs d}t        j                  ||d      5 }t        |j                         j                  d      d d       cd d d        S # 1 sw Y   y xY w)Nr
   cmdlinezutf-8r#   r$    )r   r   r   r   sysgetfilesystemencodingr'   r(   tupler+   split)r   r   r%   r.   s       r   _get_cmdliner9   4   sv    77<<S95D((*5gH		; 0q
 QVVX^^D)#2./0 0 0s   +BBc                       e Zd Zy)r   N)__name__
__module____qualname__r   r   r   r   r   ?   s    r   r   c                 4    t               fd} || |      S )z8Try to look up the process tree via the /proc interface.c              3      K   t        |      D ]2  }t        |       }t        |       }t        || |       |dk(  r y |} 4 y w)N)argsr   ppid0)ranger0   r9   r   )r   	max_depth_rA   r@   	stat_names        r   _iter_process_parentsz3iter_process_parents.<locals>._iter_process_parentsJ   sO     y! 	AS),D$Dt488s{C	s   AA)r   )r   rD   rG   rF   s      @r   iter_process_parentsrH   C   s    I
 !i00r   )
   )r'   r   rer5   _corer   r,   r-   compiler)   r   r    r0   r9   EnvironmentErrorr   rH   r   r   r   <module>rN      sX    	 	 	 
 
  rzz-(5 "0	& 	1r   