
    )i9                         S SK r S SKrSSKJrJr  SSKJrJr  \R                  " S\R                  5      r
SS jrS r\R                  " S	5      S
14/rS rS rSS jrg)    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                     [         [        4 H  n UR                  X5      nUs  $    [	        S5      e! [         a     M3  f = f)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       Z/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/shellingham/posix/__init__.py_iter_process_parentsr   %   sP     r
	00@H     N
OO   		s   3
A Ac                     [         R                  R                  SS5      nU(       a  Un OU SS n [         R                  R	                  U 5      R                  5       U 4$ )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                 "   [          H  u  p#UR                  U 5      (       d  M  U Hb  n[        R                  R	                  U5      R                  5       n[        R                  R                  U5      (       d  MV  XS;   d  M]  XT4s  s  $    M     g)a>  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   so     !9}}Y''C77##C(..0Dww~~c""t':{"  !9 r   c                    U R                  S5      (       a  [        U 5      $ [        R                  R	                  U 5      R                  5       nUS:X  d  [        R                  U5      (       a7  US   n USS  n[        R                  R	                  U 5      R                  5       nU[        ;   a  X 4$ [        X!5      nU(       a  U$ g )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$**,{{"4.Er   c                     [        U =(       d    [        R                  " 5       5      n [        X5       H  u  n  n[	        U6 nU(       d  M  Us  $    g)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   sF    
c RYY[
!C0@	1aI&5L A r   )
   )Nr:   )r   re_corer   r   r   r   r   compileVERBOSEr/   r   r   r!   r*   r4   r9    r   r   <module>r@      sg    	 	 6  	0 JJ3:P: ZZ)*WI6 
($r   