Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/sentrylogs/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/sentrylogs/__pycache__/daemonize.cpython-35.pyc



�XW�!�
@sdZddlmZddlZddlZdZdZdZdZdZdZ	d	Z
eed
�rsejZ
ndZ
dd
�Zedkre�Zdeej�ej�ej�ejd�ej�ej�ej�ej�f	Zedd�jed�eje�dS)aDisk And Execution MONitor (Daemon)

Configurable daemon behaviors:

   1.) The current working directory set to the "/" directory.
   2.) The current file creation mode mask set to 0.
   3.) Close all open files (1024).
   4.) Redirect standard I/O streams to "/dev/null".

A failed call to fork() now raises an exception.

References:
   1) Advanced Programming in the Unix Environment: W. Richard Stevens
   2) Unix Programming Frequently Asked Questions:
         http://www.erlenstar.demon.co.uk/unix/faq_toc.html
�)�_exitNzChad J. Schroederz$Copyright (C) 2005 Chad J. Schroederz$Id$z0.2�/i�devnullz	/dev/nullc(Cs�ytj�}WnAtk
rS}z!td|j|jf��WYdd}~XnX|dkr�tj�ytj�}WnAtk
r�}z!td|j|jf��WYdd}~XnX|dkr�tjt�tj	t
�q�td�n
td�ddl}|j
|j�d}||jkr5t}x=td|�D],}ytj|�WqEtk
rpYqEXqEWtjttj�tjdd�tjdd�dS)zaDetach a process from the controlling terminal and run it in the
    background as a daemon.
    z%s [%d]Nr��)�os�fork�OSError�	Exception�strerror�errno�setsid�chdir�WORKDIR�umask�UMASKr�resourceZ	getrlimitZ
RLIMIT_NOFILEZ
RLIM_INFINITY�MAXFD�range�close�open�REDIRECT_TO�O_RDWR�dup2)�pid�errrZmaxfdZ	file_desc�r�E/opt/alt/python35/lib/python3.5/site-packages/sentrylogs/daemonize.py�
create_daemon,s8/
	/

	

		r�__main__z�
    return code = %s
    process ID = %s
    parent process ID = %s
    process group ID = %s
    session ID = %s
    user ID = %s
    effective user ID = %s
    real group ID = %s
    effective group ID = %s
    zcreateDaemon.log�w�
)�__doc__rr�sys�
__author__�
__copyright__Z__revision__�__version__rrr�hasattrrrr�__name__ZRET_CODE�getpid�getppid�getpgrp�getsid�getuid�geteuid�getgid�getegidZPROC_PARAMSr�write�exitrrrr�<module>s(�	-+