Mercurial > hg
changeset 19868:0532c8f8e911
cmdutil.service: move pidfile writing to the parent in daemon mode
There is a potential race here, which I suspect I've spotted in the wild, where
something reads the pid file after the parent exits but before the child has
had a chance to write to it. Moving writing the file to the parent causes this
to no longer be an issue.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Wed, 02 Oct 2013 15:20:49 -0700 |
parents | edce20ebe1f3 |
children | 4210a05c4329 |
files | mercurial/cmdutil.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Wed Oct 02 15:17:50 2013 -0700 +++ b/mercurial/cmdutil.py Wed Oct 02 15:20:49 2013 -0700 @@ -497,6 +497,7 @@ 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 @@ if initfn: initfn() - writepid(os.getpid()) + if not opts['daemon']: + writepid(os.getpid()) if opts['daemon_pipefds']: lockpath = opts['daemon_pipefds']