HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/lib/python3/dist-packages/cloudinit/__pycache__/signal_handler.cpython-38.pyc
U

Ӈg��@sNUddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZddlmZddlmZe�e�ZdZeed<dZeed	<ejd
ejdejdiZeeeefed
<Gdd�de
�Z e dej!�Z"eed<e dej#�Z$eed<e"a%e�&�Z'eee
dfdd�dd�Z(dd�Z)dd�Z*dd�Z+ej,dd��Z-dS)�N)�StringIO)�Callable�Dict�Final�
NamedTuple�Union)�version)�log_utilz#Cloud-init {} received {}, exiting
�SIG_MESSAGE��BACK_FRAME_TRACE_DEPTHz/Cloud-init %(version)s received SIGINT, exitingz0Cloud-init %(version)s received SIGTERM, exitingz0Cloud-init %(version)s received SIGABRT, exiting�SIGNALSc@seZdZUeed<eed<dS)�ExitBehavior�	exit_code�	log_levelN)�__name__�
__module__�__qualname__�int�__annotations__�rr�:/usr/lib/python3/dist-packages/cloudinit/signal_handler.pyr s
r��SIGNAL_EXIT_BEHAVIOR_CRASH�SIGNAL_EXIT_BEHAVIOR_QUIET)�sig�returncCszt|�r"t|tj�svt�d|�nT|tjkr8t�d�n>|dkrLt�d�n*|tjkrdt�d|�nt�	dt
|�|�dS)z+inspect_handler() logs signal handler statez.Signal state [%s] - previously custom handler.z,Signal state [SIG_IGN] - previously ignored.Nz;Signal state [None] - previously not installed from Python.zISignal state [%s] - default way of handling signal was previously in use.zSignal state [%s(%s)] - unknown)�callable�
isinstance�types�BuiltinFunctionType�LOG�info�signal�SIG_IGN�SIG_DFLZwarning�type)rrrr�inspect_handler+s

�r'cCsz||ks|sdSt�|�}d|d}|�d||jf�|�d||jf�|�d||jf�t|j|d||�dS)N� �z%sFilename: %s
z%sFunction: %s
z%sLine number: %s
r)�inspectZgetframeinfo�write�filenameZfunction�lineno�
_pprint_frame�f_back)�frameZdepthZ	max_depth�contentsZ
frame_info�prefixrrrr.Bs
r.cCs^t|tj�r|jn|}tt�t��|��}t	|dt
|�tj|�
�ttjd�t�tj�dS)Nr)�logr)rr#ZSignals�namerr
�format�vrZversion_stringr.rr	Z	multi_log�getvaluer!�_SIGNAL_EXIT_BEHAVIORr�sys�exitr)�signumr0r4r1rrr�_handle_exitMs�r<cCs2d}t��D]}tt�|t��q|tt�7}|S)zattach cloud-init's handlersr)r
�keysr'r#r<�len)Z
sigs_attachedr;rrr�attach_handlersXs
r?c	cs"t�tadVtaW5QRXdS)a$suspend_crash() allows signals to be received without exiting 1

    This allow signal handling without a crash where it is expected. The
    call stack is still printed if signal is received during this context, but
    the return code is 0 and no traceback is printed.

    Threadsafe.
    N)�_SUSPEND_WRITE_LOCKrr8rrrrr�
suspend_crashasrA).�
contextlibr*Zloggingr#r9Z	threadingr�ior�typingrrrrrZ	cloudinitrr6Z
cloudinit.logr	Z	getLoggerrr!r
rr�SIGINT�SIGTERM�SIGABRTr
r�strrZERRORr�INFOrr8�RLockr@r'r.r<r?�contextmanagerrArrrr�<module>s@
�