From: Cameron Patrick Date: Sun, 1 Aug 2004 07:20:56 +0000 (+0000) Subject: add daemonising code X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=482573e7c8afad56f1c8ca0464a6cf9ac3e267f4;p=zanchey%2Fdispense2.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)