#!/usr/bin/env python #Copyright 2004 Sebastian Hagen # This file is part of eucharis. # eucharis is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 # as published by the Free Software Foundation # eucharis is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with eucharis; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #This file initializes iptrack_core. import os import sys fork_result = os.fork() #fork if (fork_result != 0): print 'Started as %s.' % (fork_result,) sys.exit(0) os.setsid() #(eval('026') == 22) which is -rw-r----- os.umask(22) import time import pid_filing import eucharis_core import socket_management import data_pickling #close stdin,stdout,stderr, and replace the latter two. #for std* to be closed correctly, os.close() has to be called #on their file descriptors. os.close(sys.stdout.fileno()) sys.stdout.close() os.close(sys.stderr.fileno()) sys.stderr.close() sys.stderr = file('stderr_iptrack.log', 'a+', 0) sys.stdout = file('stdout_iptrack.log', 'a+', 1) sys.stdout.write('%s: Starting iptrack.\n' % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),)) sys.stderr.write('%s: Starting iptrack.\n' % (time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()),)) os.close(sys.stdin.fileno()) sys.stdin.close() sys.__stderr__ = sys.__stdout__ = sys.__stdin__ = sys.stdin = None version_info = eucharis_core.version_info eucharis_core.init() import profile profile.run('socket_management.select_loop()', 'profiles/profile_eucharis_%s' % time.time()) data_pickling.save_variables()