
    D	                     H    S r SSKJr  SSKJr  SSKJr  SSKrSSKrS rS rg)zFA tiny stand alone library to change the kernel process name on Linux.    )absolute_import)division)print_functionNc                  v    [        [        R                  R                  [        R
                  S   5      5        g)zDSets the process name to something better than 'python' if possible.r   N)set_kernel_process_nameospathbasenamesysargv     ,platform/bq/third_party/absl/command_name.pymake_process_name_usefulr      s!    "''**388A;78r   c                    [        U [        5      (       d  U R                  SS5      n  [        SS5       nUR	                  U SS 5        SSS5        g! , (       d  f       g= f! [
         a     SSKnO! [         a      gf = f UR                  S5      nO! [
         a      gf = fUR                  S5      nUR                  S5      n UR                  X@XUU5         g! [         a      gf = ff = f)	a  Changes the Kernel's /proc/self/status process name on Linux.

The kernel name is NOT what will be shown by the ps or top command.
It is a 15 character string stored in the kernel's process table that
is included in the kernel log when a process is OOM killed.
The first 15 bytes of name are used.  Non-ASCII unicode is replaced with '?'.

Does nothing if /proc/self/comm cannot be written or prctl() fails.

Args:
  name: bytes|unicode, the Linux kernel's command name to set.
asciireplacez/proc/self/commwbN   r   z	libc.so.6)
isinstancebytesencodeopenwriteEnvironmentErrorctypesImportErrorCDLLc_ulongprctlAttributeError)name	proc_commr   libcpr_set_namezeros         r   r   r   !   s     
D%	 	 ;;w	*D		&)ood3Bi  
'	&	&	  [[%d ..$K>>!D
jjD5 s   A$ A
A$ 
A!A$ !A$ $
C3/A43C34
B>C3BC3BC3
B&"C3%B&&%C3C!!
C/+C3.C//C3)	__doc__
__future__r   r   r   r   r   r   r   r   r   r   <module>r)      s$    M &  % 	 
9
"r   