commit 13f3f71125efc4dfc1b953751e5409040252e64c
parent 52af40685e34ec1e76c8d0ee9ce85bcbd21d4ba9
Author: ThomasV <thomasv@electrum.org>
Date: Tue, 12 Mar 2019 08:32:27 +0100
daemon: in detached modde, redirect strandard file descriptors
Diffstat:
1 file changed, 10 insertions(+), 0 deletions(-)
diff --git a/run_electrum b/run_electrum
@@ -363,6 +363,16 @@ if __name__ == '__main__':
if pid:
print_stderr("starting daemon (PID %d)" % pid)
sys.exit(0)
+ # redirect standard file descriptors
+ sys.stdout.flush()
+ sys.stderr.flush()
+ si = open(os.devnull, 'r')
+ so = open(os.devnull, 'w')
+ se = open(os.devnull, 'w')
+ os.dup2(si.fileno(), sys.stdin.fileno())
+ os.dup2(so.fileno(), sys.stdout.fileno())
+ os.dup2(se.fileno(), sys.stderr.fileno())
+ # run daemon
init_plugins(config, 'cmdline')
d = daemon.Daemon(config, fd)
if config.get('websocket_server'):