B
    eIc                 @   s(   d Z ddlZddlZdd Zdd ZdS )zFA tiny stand alone library to change the kernel process name on Linux.    Nc               C   s   t tjtjd  dS )zDSets the process name to something better than 'python' if possible.r   N)set_kernel_process_nameospathbasenamesysargv r   r   0lib/python3.7/site-packages/absl/command_name.pymake_process_name_useful   s    r
   c             C   s   t | ts| dd} y,tdd}|| dd  W dQ R X W n tk
r   yddl}W n tk
rr   dS X y|d}W n tk
r   dS X |	d}|	d}y|
|| ||| W n tk
r   dS X Y nX dS )	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ImportErrorZCDLLZc_ulongZprctlAttributeError)nameZ	proc_commr   ZlibcZpr_set_nameZzeror   r   r	   r      s(    
 

r   )__doc__r   r   r
   r   r   r   r   r	   <module>   s   