From: Cameron Patrick Date: Sun, 1 Aug 2004 07:20:56 +0000 (+0000) Subject: add daemonising code X-Git-Tag: IMPORT-FROM-UCCCVS~83 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;ds=sidebyside;h=c43149e967896d18caaaf373ed7f75b4e98fed35;hp=30a9cbab82c9e39c70781ea4df49430ac7f694f7;p=uccvend-vendserver.git add daemonising code --- diff --git a/sql-edition/servers/VendServer.py b/sql-edition/servers/VendServer.py index 974e0b4..3c3aee6 100755 --- a/sql-edition/servers/VendServer.py +++ b/sql-edition/servers/VendServer.py @@ -434,6 +434,15 @@ def do_vend_server(): options = parse_args() config_opts = VendConfigFile(options.config_file, config_options) + if options.daemon: + dev_null = file('/dev/null') + fd = dev_null.fileno() + os.dup2(fd, 0) + os.dup2(fd, 1) + os.dup2(fd, 2) + if os.fork() != 0: + sys.exit(0) + while True: try: rfh, wfh = connect_to_vend(options, config_opts)