PHOENIX-6162 Apply PHOENIX-5594 to the phoenix-queryserver repo
diff --git a/bin/queryserver.py b/bin/queryserver.py
index 18b69d8..19e0109 100755
--- a/bin/queryserver.py
+++ b/bin/queryserver.py
@@ -149,6 +149,10 @@
         sys.stderr.write("daemon mode not supported on this platform{}".format(os.linesep))
         sys.exit(-1)
 
+    # get the current umask for the sub process
+    current_umask = os.umask(0)
+    os.umask(current_umask)
+
     # run in the background
     d = os.path.dirname(out_file_path)
     if not os.path.exists(d):
@@ -172,8 +176,12 @@
                 sys.exit(0)
             signal.signal(signal.SIGTERM, handler)
 
+            def initsubproc():
+                # set the parent's umask
+                os.umask(current_umask)
+
             print('%s launching %s' % (datetime.datetime.now(), cmd))
-            child = subprocess.Popen(cmd.split())
+            child = subprocess.Popen(cmd.split(), preexec_fn=initsubproc)
             sys.exit(child.wait())
 
 elif command == 'stop':