
    .Phc
                         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dS )    N   )Process      z
\(.+\)|\S+c            	          t          j                    } dD ]Q}t           j                            t           j                            dt          |           |                    r|c S Rt          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     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/shellingham/posix/proc.pydetect_procr      si     )++C"  7>>"',,wC$??@@ 	KKK	
3
4
44    c                  ~    	 t          j                    j                                        dv S # t          $ r Y dS w xY w)N)freebsdnetbsd	dragonflyF)r   unamesysnamelower	Exception r   r   _use_bsd_stat_formatr    #   sJ    xzz!''))-OOO   uus   +. 
<<c                 d   t           j                            dt          |           |          }t	          j        |dd          5 }t                              |                                          }d d d            n# 1 swxY w Y   t                      r|t                   S |t                   S )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   *   s    7<<S400D			:	:	: /a$$QVVXX../ / / / / / / / / / / / / / /  $]##!!s   -A??BBc                 b   t           j                            dt          |           d          }t	          j                    pd}t          j        ||d          5 }t          |	                                
                    d          d d                   cd d d            S # 1 swxY w Y   d S )Nr
   cmdlinezutf-8r#   r$    )r   r   r   r   sysgetfilesystemencodingr'   r(   tupler+   split)r   r   r%   r.   s       r   _get_cmdliner9   4   s    7<<S955D(**5gH		;	;	; 0q
 QVVXX^^D))#2#.//0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0s   <B$$B(+B(c                       e Zd ZdS )r   N)__name__
__module____qualname__r   r   r   r   r   ?   s        Dr   r   
   c                 B    t                      fd} || |          S )z8Try to look up the process tree via the /proc interface.c              3      K   t          |          D ]@}t          |           }t          |           }t          || |          V  |dk    r d S |} Ad S )N)argsr   ppid0)ranger0   r9   r   )r   	max_depth_rB   rA   	stat_names        r   _iter_process_parentsz3iter_process_parents.<locals>._iter_process_parentsJ   sv      y!! 	 	AS),,D$$Dt4888888s{{CC	 	r   )r   )r   rE   rH   rG   s      @r   iter_process_parentsrI   C   s:    I
     ! i000r   )r>   )r'   r   rer5   _corer   r,   r-   compiler)   r   r    r0   r9   EnvironmentErrorr   rI   r   r   r   <module>rN      s    				 				 				 



      
  rz-((5 5 5   " " "0 0 0	 	 	 	 	& 	 	 	1 1 1 1 1 1r   