Show More
@@ -318,13 +318,12 b' class pipeservice(object):' | |||||
318 | ui = self.ui |
|
318 | ui = self.ui | |
319 | # redirect stdio to null device so that broken extensions or in-process |
|
319 | # redirect stdio to null device so that broken extensions or in-process | |
320 | # hooks will never cause corruption of channel protocol. |
|
320 | # hooks will never cause corruption of channel protocol. | |
321 |
|
|
321 | with procutil.protectedstdio(ui.fin, ui.fout) as (fin, fout): | |
322 | try: |
|
322 | try: | |
323 | sv = server(ui, self.repo, fin, fout) |
|
323 | sv = server(ui, self.repo, fin, fout) | |
324 | return sv.serve() |
|
324 | return sv.serve() | |
325 | finally: |
|
325 | finally: | |
326 | sv.cleanup() |
|
326 | sv.cleanup() | |
327 | procutil.restorestdio(ui.fin, ui.fout, fin, fout) |
|
|||
328 |
|
327 | |||
329 | def _initworkerprocess(): |
|
328 | def _initworkerprocess(): | |
330 | # use a different process group from the master process, in order to: |
|
329 | # use a different process group from the master process, in order to: |
@@ -9,6 +9,7 b'' | |||||
9 |
|
9 | |||
10 | from __future__ import absolute_import |
|
10 | from __future__ import absolute_import | |
11 |
|
11 | |||
|
12 | import contextlib | |||
12 | import imp |
|
13 | import imp | |
13 | import io |
|
14 | import io | |
14 | import os |
|
15 | import os | |
@@ -240,6 +241,15 b' def restorestdio(uin, uout, fin, fout):' | |||||
240 | os.dup2(f.fileno(), uif.fileno()) |
|
241 | os.dup2(f.fileno(), uif.fileno()) | |
241 | f.close() |
|
242 | f.close() | |
242 |
|
243 | |||
|
244 | @contextlib.contextmanager | |||
|
245 | def protectedstdio(uin, uout): | |||
|
246 | """Run code block with protected standard streams""" | |||
|
247 | fin, fout = protectstdio(uin, uout) | |||
|
248 | try: | |||
|
249 | yield fin, fout | |||
|
250 | finally: | |||
|
251 | restorestdio(uin, uout, fin, fout) | |||
|
252 | ||||
243 | def shellenviron(environ=None): |
|
253 | def shellenviron(environ=None): | |
244 | """return environ with optional override, useful for shelling out""" |
|
254 | """return environ with optional override, useful for shelling out""" | |
245 | def py2shell(val): |
|
255 | def py2shell(val): |
General Comments 0
You need to be logged in to leave comments.
Login now