diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -497,6 +497,7 @@ def service(opts, parentfn=None, initfn= pid = util.rundetached(runargs, condfn) if pid < 0: raise util.Abort(_('child process failed to start')) + writepid(pid) finally: try: os.unlink(lockpath) @@ -511,7 +512,8 @@ def service(opts, parentfn=None, initfn= if initfn: initfn() - writepid(os.getpid()) + if not opts['daemon']: + writepid(os.getpid()) if opts['daemon_pipefds']: lockpath = opts['daemon_pipefds']