mercurial/cmdutil.py
changeset 28195 213c8cf02c49
parent 28194 7623ba92af72
child 28218 41dcd7545266
equal deleted inserted replaced
28194:7623ba92af72 28195:213c8cf02c49
   763         lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
   763         lockfd, lockpath = tempfile.mkstemp(prefix='hg-service-')
   764         os.close(lockfd)
   764         os.close(lockfd)
   765         try:
   765         try:
   766             if not runargs:
   766             if not runargs:
   767                 runargs = util.hgcmd() + sys.argv[1:]
   767                 runargs = util.hgcmd() + sys.argv[1:]
   768             runargs.append('--daemon-postexec=%s' % lockpath)
   768             runargs.append('--daemon-postexec=unlink:%s' % lockpath)
   769             # Don't pass --cwd to the child process, because we've already
   769             # Don't pass --cwd to the child process, because we've already
   770             # changed directory.
   770             # changed directory.
   771             for i in xrange(1, len(runargs)):
   771             for i in xrange(1, len(runargs)):
   772                 if runargs[i].startswith('--cwd='):
   772                 if runargs[i].startswith('--cwd='):
   773                     del runargs[i]
   773                     del runargs[i]
   797 
   797 
   798     if not opts['daemon']:
   798     if not opts['daemon']:
   799         writepid(util.getpid())
   799         writepid(util.getpid())
   800 
   800 
   801     if opts['daemon_postexec']:
   801     if opts['daemon_postexec']:
   802         lockpath = opts['daemon_postexec']
   802         inst = opts['daemon_postexec']
   803         try:
   803         try:
   804             os.setsid()
   804             os.setsid()
   805         except AttributeError:
   805         except AttributeError:
   806             pass
   806             pass
   807         os.unlink(lockpath)
   807         if inst.startswith('unlink:'):
       
   808             lockpath = inst[7:]
       
   809             os.unlink(lockpath)
       
   810         elif inst != 'none':
       
   811             raise error.Abort(_('invalid value for --daemon-postexec'))
   808         util.hidewindow()
   812         util.hidewindow()
   809         sys.stdout.flush()
   813         sys.stdout.flush()
   810         sys.stderr.flush()
   814         sys.stderr.flush()
   811 
   815 
   812         nullfd = os.open(os.devnull, os.O_RDWR)
   816         nullfd = os.open(os.devnull, os.O_RDWR)