
    ,h9                         d dl Z d dlZddlmZmZ ddlmZmZ  ej                  dej                        Z
ddZd Z ej                  d	      d
hfgZd Zd ZddZy)    N   )SHELL_NAMESShellDetectionFailure   )procpsad  qemu-
        (alpha
        |armeb
        |arm
        |m68k
        |cris
        |i386
        |x86_64
        |microblaze
        |mips
        |mipsel
        |mips64
        |mips64el
        |mipsn32
        |mipsn32el
        |nios2
        |ppc64
        |ppc
        |sh4eb
        |sh4
        |sparc
        |sparc32plus
        |sparc64
    )c                     t         t        fD ]  }	 |j                  | |      }|c S  t	        d      # t        $ r Y 1w xY w)zSelect a way to obtain process information from the system.

    * `/proc` is used if supported.
    * The system `ps` utility is used as a fallback option.
    z,compatible proc fs or ps utility is required)r   r   iter_process_parentsEnvironmentErrorr   )pid	max_depthimpliterators       \/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/shellingham/posix/__init__.py_iter_process_parentsr   %   sW     r
 	00i@H    N
OO   		s   3	??c                     t         j                  j                  dd      }|r|} n| dd } t         j                  j	                  |       j                         | fS )z6Form shell information from SHELL environ if possible.SHELL r   N)osenvirongetpathbasenamelower)proc_cmdlogin_shells     r   _get_login_shellr   4   sL    **.."-KAB<GGX&,,.99    z^python(\d+(\.\d+)?)?$xonshc                    t         D ]w  \  }}|j                  |       s|D ][  }t        j                  j	                  |      j                         }t        j                  j                  |      sP||v sU||fc c S  y y)aV  Get shell invoked via an interpreter.

    Some shells are implemented on, and invoked with an interpreter, e.g. xonsh
    is commonly executed with an executable Python script. This detects what
    script the interpreter is actually running, and check whether that looks
    like a shell.

    See sarugaku/shellingham#26 for rational.
    N)_INTERPRETER_SHELL_NAMESmatchr   r   r   r   isfile)	proc_name	proc_argspatternshell_namesargnames         r   _get_interpreter_shellr*   C   sy     !9 #}}Y' 	#C77##C(..0Dww~~c"t{':c{"	## r   c                 p   | j                  d      rt        |       S t        j                  j	                  |       j                         }|dk(  st        j                  |      r7|d   } |dd  }t        j                  j	                  |       j                         }|t        v r|| fS t        ||      }|r|S y )N-rosettar   r   )

startswithr   r   r   r   r   QEMU_BIN_REGEX	fullmatchr   r*   )cmdargsr)   shells       r   
_get_shellr4   W   s    
~~c$$77C &&(DyN44T: 1gABxww$**,{c{"4.Er   c                     t        | xs t        j                               } t        | |      D ]  \  }}}t	        | }|s|c S  y)zAGet the shell that the supplied pid or os.getpid() is running in.N)strr   getpidr   r4   )r   r   r%   _r3   s        r   	get_shellr9   i   sJ    
c RYY[
!C0i@ 	1aI&L r   )
   )Nr:   )r   re_corer   r   r   r   r   compileVERBOSEr/   r   r   r!   r*   r4   r9    r   r   <module>r@      sk    	 	 6  	0 JJ3:P: RZZ)*WI6 
($r   