equal
deleted
inserted
replaced
42 from mercurial import ( |
42 from mercurial import ( |
43 encoding, |
43 encoding, |
44 pycompat, |
44 pycompat, |
45 ) |
45 ) |
46 |
46 |
|
47 from mercurial.utils import ( |
|
48 procutil, |
|
49 ) |
|
50 |
47 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
51 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for |
48 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
52 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should |
49 # be specifying the version(s) of Mercurial they are tested with, or |
53 # be specifying the version(s) of Mercurial they are tested with, or |
50 # leave the attribute unspecified. |
54 # leave the attribute unspecified. |
51 testedwith = 'ships-with-hg-core' |
55 testedwith = 'ships-with-hg-core' |
60 |
64 |
61 def runshellcommand(script, env): |
65 def runshellcommand(script, env): |
62 # we can't use close_fds *and* redirect stdin. I'm not sure that we |
66 # we can't use close_fds *and* redirect stdin. I'm not sure that we |
63 # need to because the detached process has no console connection. |
67 # need to because the detached process has no console connection. |
64 subprocess.Popen( |
68 subprocess.Popen( |
65 script, shell=True, env=env, close_fds=True, |
69 pycompat.rapply(procutil.tonativestr, script), |
|
70 shell=True, env=procutil.tonativeenv(env), close_fds=True, |
66 creationflags=_creationflags) |
71 creationflags=_creationflags) |
67 else: |
72 else: |
68 def runshellcommand(script, env): |
73 def runshellcommand(script, env): |
69 # double-fork to completely detach from the parent process |
74 # double-fork to completely detach from the parent process |
70 # based on http://code.activestate.com/recipes/278731 |
75 # based on http://code.activestate.com/recipes/278731 |
80 newsession = {'start_new_session': True} |
85 newsession = {'start_new_session': True} |
81 try: |
86 try: |
82 # connect stdin to devnull to make sure the subprocess can't |
87 # connect stdin to devnull to make sure the subprocess can't |
83 # muck up that stream for mercurial. |
88 # muck up that stream for mercurial. |
84 subprocess.Popen( |
89 subprocess.Popen( |
85 script, shell=True, stdin=open(os.devnull, 'r'), env=env, |
90 pycompat.rapply(procutil.tonativestr, script), |
|
91 shell=True, stdin=open(os.devnull, 'r'), |
|
92 env=procutil.tonativeenv(env), |
86 close_fds=True, **newsession) |
93 close_fds=True, **newsession) |
87 finally: |
94 finally: |
88 # mission accomplished, this child needs to exit and not |
95 # mission accomplished, this child needs to exit and not |
89 # continue the hg process here. |
96 # continue the hg process here. |
90 os._exit(0) |
97 os._exit(0) |