B ÿ‚Û_mã@s^dZddlZddlZddlZddlZddlZddlmZddlmZddlm Z ddlm Z ddl m Z dd l m Z dd l mZdd l mZdd l mZdd l mZddl mZejdkrÄddlZndZddddgZdd„Zedk �reedƒ�re dedd„ejDƒƒ¡Zdd„Zndd„Zddejeedejƒeej efdd„Z!dd„Z"edd„ƒZ#dS) z%Routines common to all posix systems.éNé)Úmemoize)Ú sdiskusage)ÚTimeoutExpired)Ú usage_percent)ÚChildProcessError)ÚFileNotFoundError)ÚInterruptedError)ÚPermissionError)ÚProcessLookupError)ÚPY3)Úunicode)ééÚ pid_existsÚwait_pidÚ disk_usageÚget_terminal_mapcCsL|dkr dSyt |d¡Wn&tk r0dStk rBdSXdSdS)z6Check whether pid exists in the current process table.rTFN)ÚosÚkillr r )Úpid©rúB/opt/alt/python37/lib64/python3.7/site-packages/psutil/_psposix.pyr"sÚSignalsÚ NegsignalcCsg|]}|j|j f‘qSr)ÚnameÚvalue)Ú.0Úxrrrú <srcCs"yt|ƒStk r|SXdS)z+Convert a negative signal value to an enum.N)rÚ ValueError)ÚnumrrrÚnegsig_to_enum>sr"cCs|S)Nr)r!rrrr"EsÚ monotonicc sþˆdkrtdƒ‚d}d} ˆdk r4| tjO} ˆƒˆ‰‡‡‡‡‡‡‡fdd„} x¬yt ˆ| ¡\} } WnDtk r~| |ƒ}YqNtk r¦x|ˆƒr | |ƒ}qŽWdSX| dkr¼| |ƒ}qNqNt | ¡rÐt | ¡St | ¡rêt t  | ¡ ƒStd| ƒ‚qNWdS)a›Wait for a process PID to terminate. If the process terminated normally by calling exit(3) or _exit(2), or by returning from main(), the return value is the positive integer passed to *exit(). If it was terminated by a signal it returns the negated value of the signal which caused the termination (e.g. -SIGTERM). If PID is not a children of os.getpid() (current process) just wait until the process disappears and return None. If PID does not exist at all return None immediately. If *timeout* != None and process is still alive raise TimeoutExpired. timeout=0 is also possible (either return immediately or raise). rzcan't wait for PID 0g-Cëâ6?Ncs6ˆdk r ˆƒˆkr tˆˆˆd�‚ˆ|ƒˆ|ddƒS)N)rrég{®Gáz¤?)r)Úinterval)Ú_minÚ_sleepÚ_timerrÚ proc_nameÚstop_atÚtimeoutrrÚsleephs  zwait_pid..sleepzunknown process exit status %r) r rÚWNOHANGÚwaitpidr rÚ WIFEXITEDÚ WEXITSTATUSÚ WIFSIGNALEDr"ÚWTERMSIG) rr+r)Ú_waitpidr(r&r'Z _pid_existsr%Úflagsr,ZretpidÚstatusr)r&r'r(rr)r*r+rrIs2         c CsÆtrt |¡}ndyt |¡}WnTtk rrt|tƒrly| t ¡¡}Wntk r^YnXt |¡}n‚YnX|j |j }|j |j }|j |j }||}||}t ||dd�}t||||d�S)a.Return disk usage associated with path. Note: UNIX usually reserves 5% disk space which is not accessible by user. In this function "total" and "used" values reflect the total and used disk space whereas "free" and "percent" represent the "free" and "used percent" user disk space. r)Úround_)ÚtotalÚusedÚfreeÚpercent)r rÚstatvfsÚUnicodeEncodeErrorÚ isinstancer ÚencodeÚsysÚgetfilesystemencodingÚf_blocksÚf_frsizeÚf_bfreeÚf_bavailrr)ÚpathÚstr7Z avail_to_rootZ avail_to_userr8Z total_userZusage_percent_userrrrr¡s(      c Csdi}t d¡t d¡}xF|D]>}||ks2t|ƒ‚y||t |¡j<Wqtk rZYqXqW|S)zMGet a map of device-id -> path as a dict. Used by Process.terminal() z /dev/tty*z /dev/pts/*)ÚglobÚAssertionErrorrÚstatÚst_rdevr)ÚretZlsrrrrrÒs  )$Ú__doc__rGrÚsignalr?ÚtimeÚ_commonrrrrÚ_compatrrr r r r r Ú version_infoÚenumÚ__all__rÚhasattrÚIntEnumÚdictrrr"r.ÚgetattrÚminr,rrrrrrrÚsD                 S1