[PATCH 1 of 2] cmdutil.service: do not _exit(0) in the parent process

Nicolas Dumazet nicdumz at gmail.com
Tue Nov 17 01:22:37 CST 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1258437600 -32400
# Node ID 2b925ed9433ede6590835f283a28ecaa8b9baee3
# Parent  57949bfec718c467f02bd4e9c2bfb8e24d001a5b
cmdutil.service: do not _exit(0) in the parent process

The fact that a parent process spawns a daemon does not necessarily means that
it is the only think it has to do. This was forcing since 7c01599dd340 inotify
processes launched implicitely to exit prematurely:
when no inotify server was running, "hg st" for example would only launch a
inotify server, _exit(0) and thus would not return file statuses.

This changeset adds a test for implicitely launched inotify processes.
Change to output of test-inotify-1208 is correct: it reflects the normal
error message of "hg st" when not dying during "hg inserve" daemon creation.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -571,7 +571,7 @@
         if parentfn:
             return parentfn(pid)
         else:
-            os._exit(0)
+            return
 
     if initfn:
         initfn()
diff --git a/tests/test-inotify b/tests/test-inotify
--- a/tests/test-inotify
+++ b/tests/test-inotify
@@ -2,7 +2,8 @@
 
 "$TESTDIR/hghave" inotify || exit 80
 
-hg init
+hg init repo1
+cd repo1
 
 touch a b c d e
 mkdir dir
@@ -10,10 +11,18 @@
 touch dir/x dir/y dir/bar/foo
 
 hg ci -Am m
+cd ..
+hg clone repo1 repo2
 
 echo "[extensions]" >> $HGRCPATH
 echo "inotify=" >> $HGRCPATH
 
+cd repo2
+echo b >> a
+# check that daemon started automatically works correctly
+hg status
+
+cd ../repo1
 echo % inserve
 hg inserve -d --pid-file=hg.pid
 cat hg.pid >> "$DAEMON_PIDS"
diff --git a/tests/test-inotify-issue1208.out b/tests/test-inotify-issue1208.out
--- a/tests/test-inotify-issue1208.out
+++ b/tests/test-inotify-issue1208.out
@@ -1,5 +1,6 @@
 % fail
 abort: could not start server: File exists
+could not talk to new inotify server: No such file or directory
 abort: could not start server: File exists
 % inserve
 % status
diff --git a/tests/test-inotify.out b/tests/test-inotify.out
--- a/tests/test-inotify.out
+++ b/tests/test-inotify.out
@@ -6,6 +6,9 @@
 adding dir/x
 adding dir/y
 adding e
+updating to branch default
+8 files updated, 0 files merged, 0 files removed, 0 files unresolved
+M a
 % inserve
 ? hg.pid
 % clean


More information about the Mercurial-devel mailing list