daemon: Minor code reorganization.

This commit is contained in:
Tom Goff 2016-01-29 18:21:49 -05:00
parent 0dcf2c05f0
commit 104d05a4be
2 changed files with 9 additions and 8 deletions

View file

@ -12,6 +12,11 @@ procedures.
'''
import subprocess, os, ast
import fcntl
def closeonexec(fd):
fdflags = fcntl.fcntl(fd, fcntl.F_GETFD)
fcntl.fcntl(fd, fcntl.F_SETFD, fdflags | fcntl.FD_CLOEXEC)
def checkexec(execlist):
for bin in execlist:
@ -265,6 +270,6 @@ def checkforkernelmodule(name):
'''
with open('/proc/modules', 'r') as f:
for line in f:
if line[:len(name)] == name:
return line
if line.startswith(name + ' '):
return line.rstrip()
return None

View file

@ -13,7 +13,7 @@ messages and instantiates emulated nodes and networks within the kernel. Various
message handlers are defined and some support for sending messages.
'''
import SocketServer, fcntl, struct, sys, threading, time, traceback
import SocketServer, struct, sys, threading, time, traceback
import os, optparse, ConfigParser, gc, shlex, socket, shutil
import atexit
import signal
@ -34,7 +34,7 @@ except ImportError:
from core.constants import *
from core.api import coreapi
from core.coreobj import PyCoreNet
from core.misc.utils import hexdump, daemonize, cmdresult, mutedetach
from core.misc.utils import hexdump, daemonize, cmdresult, mutedetach, closeonexec
from core.misc.xmlsession import opensessionxml, savesessionxml
DEFAULT_MAXFD = 1024
@ -68,10 +68,6 @@ coreapi.add_node_class("CORE_NODE_TUNNEL",
coreapi.add_node_class("CORE_NODE_EMANE",
coreapi.CORE_NODE_EMANE, pycore.nodes.EmaneNode)
def closeonexec(fd):
fdflags = fcntl.fcntl(fd, fcntl.F_GETFD)
fcntl.fcntl(fd, fcntl.F_SETFD, fdflags | fcntl.FD_CLOEXEC)
class CoreRequestHandler(SocketServer.BaseRequestHandler):
''' The SocketServer class uses the RequestHandler class for servicing
requests, mainly through the handle() method. The CoreRequestHandler