Show More
@@ -546,24 +546,26 b' def copy(ui, repo, pats, opts, rename=Fa' | |||||
546 |
|
546 | |||
547 | return errors |
|
547 | return errors | |
548 |
|
548 | |||
549 |
def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None |
|
549 | def service(opts, parentfn=None, initfn=None, runfn=None, logfile=None, | |
|
550 | runargs=None): | |||
550 | '''Run a command as a service.''' |
|
551 | '''Run a command as a service.''' | |
551 |
|
552 | |||
552 | if opts['daemon'] and not opts['daemon_pipefds']: |
|
553 | if opts['daemon'] and not opts['daemon_pipefds']: | |
553 | rfd, wfd = os.pipe() |
|
554 | rfd, wfd = os.pipe() | |
554 | args = sys.argv[:] |
|
555 | if not runargs: | |
555 | args.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) |
|
556 | runargs = sys.argv[:] | |
|
557 | runargs.append('--daemon-pipefds=%d,%d' % (rfd, wfd)) | |||
556 | # Don't pass --cwd to the child process, because we've already |
|
558 | # Don't pass --cwd to the child process, because we've already | |
557 | # changed directory. |
|
559 | # changed directory. | |
558 | for i in xrange(1,len(args)): |
|
560 | for i in xrange(1,len(runargs)): | |
559 | if args[i].startswith('--cwd='): |
|
561 | if runargs[i].startswith('--cwd='): | |
560 | del args[i] |
|
562 | del runargs[i] | |
561 | break |
|
563 | break | |
562 | elif args[i].startswith('--cwd'): |
|
564 | elif runargs[i].startswith('--cwd'): | |
563 | del args[i:i+2] |
|
565 | del runargs[i:i+2] | |
564 | break |
|
566 | break | |
565 | pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), |
|
567 | pid = os.spawnvp(os.P_NOWAIT | getattr(os, 'P_DETACH', 0), | |
566 | args[0], args) |
|
568 | runargs[0], runargs) | |
567 | os.close(wfd) |
|
569 | os.close(wfd) | |
568 | os.read(rfd, 1) |
|
570 | os.read(rfd, 1) | |
569 | if parentfn: |
|
571 | if parentfn: |
General Comments 0
You need to be logged in to leave comments.
Login now