예제 #1
0
def main():
    global daemon
    inventoryd.localData.cli = inventoryd.getcliargs()
    inventoryd.localData.cfg = inventoryd.getconfig(inventoryd.localData.cli.configpath)
    
    if inventoryd.localData.cli.daemonize is True:

        try:
            pid = os.fork()
        except OSError, e:
            raise Exception, "%s [%d]" % (e.strerror, e.errno)
        
        if pid == 0:
            os.setsid()
            try:
                pid = os.fork()
            except OSError, e:
                raise Exception, "%s [%d]" % (e.strerror, e.errno)
            
            if pid == 0:
                os.chdir("/")
                os.umask(0)
                daemon = inventoryd.daemon()
                daemon.start()

                signal.signal(signal.SIGINT, signal_handler)
                signal.pause()
                sys.exit(0)
            else:
                os._exit(0)
예제 #2
0
def main():
    global daemon
    inventoryd.localData.cli = inventoryd.getcliargs()
    inventoryd.localData.cfg = inventoryd.getconfig(
        inventoryd.localData.cli.configpath)

    if inventoryd.localData.cli.daemonize is True:

        try:
            pid = os.fork()
        except OSError, e:
            raise Exception, "%s [%d]" % (e.strerror, e.errno)

        if pid == 0:
            os.setsid()
            try:
                pid = os.fork()
            except OSError, e:
                raise Exception, "%s [%d]" % (e.strerror, e.errno)

            if pid == 0:
                os.chdir("/")
                os.umask(0)
                daemon = inventoryd.daemon()
                daemon.start()

                signal.signal(signal.SIGINT, signal_handler)
                signal.pause()
                sys.exit(0)
            else:
                os._exit(0)
예제 #3
0
            
            if pid == 0:
                os.chdir("/")
                os.umask(0)
                daemon = inventoryd.daemon()
                daemon.start()

                signal.signal(signal.SIGINT, signal_handler)
                signal.pause()
                sys.exit(0)
            else:
                os._exit(0)
        else:
            os._exit(0)
    else:
        daemon = inventoryd.daemon()
        daemon.start()

        signal.signal(signal.SIGINT, signal_handler)
        signal.pause()
        sys.exit(0)

    
def signal_handler(signal, frame):
    global daemon
    daemon.stop()
    sys.exit(0)



if __name__ == '__main__':
예제 #4
0
            if pid == 0:
                os.chdir("/")
                os.umask(0)
                daemon = inventoryd.daemon()
                daemon.start()

                signal.signal(signal.SIGINT, signal_handler)
                signal.pause()
                sys.exit(0)
            else:
                os._exit(0)
        else:
            os._exit(0)
    else:
        daemon = inventoryd.daemon()
        daemon.start()

        signal.signal(signal.SIGINT, signal_handler)
        signal.pause()
        sys.exit(0)


def signal_handler(signal, frame):
    global daemon
    daemon.stop()
    sys.exit(0)


if __name__ == '__main__':
    main()