HEX
Server: LiteSpeed
System: Linux shams.tasjeel.ae 5.14.0-611.5.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 11 08:09:09 EST 2025 x86_64
User: infowars (1469)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.9/site-packages/borg/helpers/__pycache__/process.cpython-39.opt-1.pyc
a

HZ�h�:�@svddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZmZmZddlmZe�ZddlmZmZmZmZejdd��Zd	d
�Zejdd�d
d��ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Z ejdd��Z!dd�Z"Gdd�d�Z#e#�Z$dd�Z%d*e&d �d!d"�Z'ej(fd#d$�Z)d+d%d&�Z*ejd,d(d)��Z+dS)-�N�)�__version__)�is_win32�is_linux�
is_freebsd�	is_darwin)�
create_logger)�EXIT_SUCCESS�EXIT_WARNING�EXIT_SIGNAL_BASE�Errorc
cs@ddlm}|�}t��}|r�t}zVz|dfVWn*ty\}z|j}WYd}~n
d}~00Wt�d|�t�	|�nt�d|�t�	|�0t�
�t��}|r�t�	d�t�d�t�d�t�d�t�
tjtj�}t�|d�t�|d�|�}z$||fVWt�d�t�|d�nt�d�t�|d�0dS)Nr)�get_process_idz:Daemonizing: Foreground process (%s, %s, %s) is now dying.r�/�)�platformr
�os�forkr	�_ExitCodeException�	exit_code�logger�debug�_exit�setsid�chdir�close�open�devnull�O_RDWR�dup2)r
�old_id�pidr�e�fd�new_id�r$�:/usr/lib64/python3.9/site-packages/borg/helpers/process.py�
_daemonizes<�




�
r&cCs6t��\}}||fWd�S1s(0YdS)zsDetach process from controlling terminal and run in background

    Returns: old and new get_process_id tuples
    N)r&)rr#r$r$r%�	daemonize7sr'�)�timeoutccs�t����\}}|du�r�t�d|�t}tdtt����Ftdtt����tdtt����z�z|dkrtt	�
|�Wn�ty�Yn�ty�t}Yn�ty�t�d|�td}YnZt
�y}z2t�d	d
�t�|j||j���t}WYd}~nd}~00t�d�t}Wt|��n
t|��0Wd�n1�sH0YWd�n1�sh0YWd�n1�s�0Ytj}t�d|�z�z||fVWnRt
�y}z8tj}t�d
d
�t�|j||j���|�WYd}~nd}~00t�d|�Wzt�|d|�WnHt
�yv}z.t�dd
�t�|j||j���WYd}~n
d}~00n`zt�|d|�WnHt
�y�}z.t�dd
�t�|j||j���WYd}~n
d}~000Wd�n1�s�0YdS)aDLike daemonize(), but as context manager.

    The with-body is executed in the background process,
    while the foreground process survives until the body is left
    or the given timeout is exceeded. In the latter case a warning is
    reported by the foreground.
    Context variable is (old_id, new_id) get_process_id tuples.
    An exception raised in the body is reported by the foreground
    as a warning as well as propagated outside the body in the background.
    In case of a warning, the foreground exits with exit code EXIT_WARNING
    instead of EXIT_SUCCESS.
    NzQDaemonizing: Foreground process (%s, %s, %s) is waiting for background process...�SIGINT�SIGHUP�SIGTERMrz=Daemonizing: Foreground process (%s, %s, %s) received SIGINT.rzEDaemonizing: Foreground process received an exception while waiting:
�zGDaemonizing: Background process did not respond (timeout). Is it alive?z;Daemonizing: Background process (%s, %s, %s) is starting...zDDaemonizing: Background process raised an exception while starting:
z9Daemonizing: Background process (%s, %s, %s) has started.rzHDaemonizing: Trying to kill the foreground process raised an exception:
)r&rrr	�signal_handler�raising_signal_handler�KeyboardInterrupt�SigHup�SigTerm�time�sleepr
r�
BaseExceptionZwarning�join�	traceback�format_exception�	__class__�
__traceback__r�signalr,r+r�kill�error)r)rr#rr!Zsig_to_foregroundr$r$r%�daemonizing@sd
���
t����r>c@seZdZdd�ZdS)rcCs
||_dS�N)r)�selfrr$r$r%�__init__�sz_ExitCodeException.__init__N)�__name__�
__module__�__qualname__rAr$r$r$r%r�src@seZdZdZdS)�SignalExceptionz*base class for all signal-based exceptionsN�rBrCrD�__doc__r$r$r$r%rE�srEc@seZdZdZdS)r1zraised on SIGHUP signalNrFr$r$r$r%r1�sr1c@seZdZdZdS)r2zraised on SIGTERM signalNrFr$r$r$r%r2�sr2c
csdt|t�rtt|d�}|dur*t�||�}zdVW|dur`t�||�n|dur^t�||�0dS)a�
    when entering context, set up signal handler <handler> for signal <sig>.
    when leaving context, restore original signal handler.

    <sig> can bei either a str when giving a signal.SIGXXX attribute name (it
    won't crash if the attribute name does not exist as some names are platform
    specific) or a int, when giving a signal number.

    <handler> is any handler value as accepted by the signal.signal(sig, handler).
    N)�
isinstance�str�getattrr;)Zsig�handlerZorig_handlerr$r$r%r.�s
�r.cs�fdd�}|S)Ncst�|tj���dSr?)r;�SIG_IGN)�sig_no�frame��exc_clsr$r%rK�sz'raising_signal_handler.<locals>.handlerr$)rPrKr$rOr%r/�sr/c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�
SigIntManagercCs0d|_d|_d|_td|j�|_d|_d|_dS)NFr*i-1)�_sig_int_triggered�_action_triggered�_action_doner.rK�ctx�debounce_interval�last�r@r$r$r%rA�szSigIntManager.__init__cCs|jSr?)rRrXr$r$r%�__bool__�szSigIntManager.__bool__cCs|jSr?)rSrXr$r$r%�action_triggered�szSigIntManager.action_triggeredcCs|jSr?)rTrXr$r$r%�action_done�szSigIntManager.action_donecCsd|_d|_dS)NFT)rSrTrXr$r$r%�action_completed�szSigIntManager.action_completedcCsLt��}|jdur&||_d|_d|_n"||j|jkrH|�ddd�t�dS)NT)r3�monotonic_nsrWrRrSrV�__exit__r0)r@rM�stackZnowr$r$r%rK�s
zSigIntManager.handlercCs|j��dSr?)rU�	__enter__rXr$r$r%r`�szSigIntManager.__enter__cCs |jr|j�|||�d|_dSr?)rUr^)r@Zexception_typeZexception_valuer7r$r$r%r^�szSigIntManager.__exit__N)rBrCrDrArYrZr[r\rKr`r^r$r$r$r%rQ�srQcCst�tjtj�dS)aW
    Ignore SIGINT, see also issue #6912.

    Ctrl-C will send a SIGINT to both the main process (borg) and subprocesses
    (e.g. ssh for remote ssh:// repos), but often we do not want the subprocess
    getting killed (e.g. because it is still needed to cleanly shut down borg).

    To avoid that: Popen(..., preexec_fn=ignore_sigint)
    N)r;r*rLr$r$r$r%�
ignore_sigint�s
rar-)�cmd_linec
Ks�zt�|�}|std��Wn4tyN}zt�d||�WYd}~dSd}~00t�d||�ztj|fi|��WSty�t�d||d�YdSt	y�t�d||d�YdS0dS)as
    Handle typical errors raised by subprocess.Popen. Return None if an error occurred,
    otherwise return the Popen object.

    *cmd_line* is split using shlex (e.g. 'gzip -9' => ['gzip', '-9']).

    Log messages will be prefixed with *log_prefix*; if set, it should end with a space
    (e.g. log_prefix='--some-option: ').

    Does not change the exit code.
    z&an empty command line is not permittedz%s%sNz%scommand line: %sz%sexecutable not found: %srz%spermission denied: %s)
�shlex�split�
ValueErrorrr=r�
subprocess�Popen�FileNotFoundError�PermissionError)rb�
log_prefix�kwargsZcommand�ver$r$r%�popen_with_error_handlings 

rmcCs"t|d�o |��o tp dtjvS)N�isattyZANSICON)�hasattrrnrr�environ)r"r$r$r%�is_terminal!srqcCs�t|dur|ntj�}|rpd}|�|d�}|dur>|||<n2|�|�}|durpttdd�rpttd�rp|�|�|�dd�t|d<|S)	a
    Prepare the environment for a subprocess we are going to create.

    :param system: True for preparing to invoke system-installed binaries,
                   False for stuff inside the pyinstaller environment (like borg, python).
    :param env: optionally give a environment dict here. if not given, default to os.environ.
    :return: a modified copy of the environment
    NZLD_LIBRARY_PATHZ_ORIG�frozenFZ_MEIPASSZBORG_PASSPHRASEZBORG_VERSION)	�dictrrp�getrJ�sysro�popr)�system�envZlp_keyZlp_origZlpr$r$r%�prepare_subprocess_env%s	



ryTc

csp|rr|}|}tdd�}|r2t|tj|d|td�}nt|tj|d|td�}|s\td|�d���|rf|jn|j}|}z�z
|VWn.ty�t	�
d�|r�|��d	}�Yn0d}W|r�|��|�rlt	�
d
�|�
�}	t	�
d|	�|r�|��|�rl|	�rltd||	f��n^|�r|��|�rjt	�
d
�|�
�}	t	�
d|	�|�rN|��|�rj|	�rjtd||	f��0dS)
NT)rwzfilter-process: )�stdout�stdinrjrx�
preexec_fn)r{rzrjrxr|zfilter z: process creation failedz Exception, killing the filter...Fz"Done, waiting for filter to die...zfilter cmd exited with code %dzfilter %s failed, rc=%d)ryrmrf�PIPErarrzr{�	Exceptionrrr<r�wait)
�cmd�streamZstream_closeZinboundZ
filter_streamZfilter_stream_closerx�procZborg_succeeded�rcr$r$r%�create_filter_processKsX

�
�


�
r�)r-)N)T),�
contextlibrZos.path�rercr;rfrur3r7r-rZ
platformflagsrrrrrrZhelpersr	r
rr�contextmanagerr&r'r>r5rrEr1r2r.r/rQZsig_intrarIrmrzrqryr�r$r$r$r%�<module>sD
!	E
9

&