changeset 1741:9777298fed84

stop read end of pipe from staying open forever in child process.
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Fri, 17 Feb 2006 16:32:07 -0800
parents f95654385065
children 1e5bb6c929cd
files mercurial/commands.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Fri Feb 17 16:29:30 2006 -0800
+++ b/mercurial/commands.py	Fri Feb 17 16:32:07 2006 -0800
@@ -2022,10 +2022,10 @@
         if opts[o]:
             ui.setconfig("web", o, opts[o])
 
-    if opts['daemon'] and not opts['daemon_pipefd']:
+    if opts['daemon'] and not opts['daemon_pipefds']:
         rfd, wfd = os.pipe()
         args = sys.argv[:]
-        args.append('--daemon-pipefd=' + str(wfd))
+        args.append('--daemon-pipefds=%d,%d' % (rfd, wfd))
         pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0),
                          args[0], args)
         os.close(wfd)
@@ -2056,8 +2056,9 @@
         fp.write(str(os.getpid()))
         fp.close()
 
-    if opts['daemon_pipefd']:
-        wfd = int(opts['daemon_pipefd'])
+    if opts['daemon_pipefds']:
+        rfd, wfd = [int(x) for x in opts['daemon_pipefds'].split(',')]
+        os.close(rfd)
         os.write(wfd, 'y')
         os.close(wfd)
         sys.stdout.flush()
@@ -2505,7 +2506,7 @@
         (serve,
          [('A', 'accesslog', '', _('name of access log file to write to')),
           ('d', 'daemon', None, _('run server in background')),
-          ('', 'daemon-pipefd', '', ''),
+          ('', 'daemon-pipefds', '', ''),
           ('E', 'errorlog', '', _('name of error log file to write to')),
           ('p', 'port', 0, _('port to use (default: 8000)')),
           ('a', 'address', '', _('address to use')),