Show More
@@ -635,21 +635,35 b' if pycompat.iswindows:' | |||
|
635 | 635 | stderr=None, |
|
636 | 636 | ensurestart=True, |
|
637 | 637 | record_wait=None, |
|
638 | stdin_bytes=None, | |
|
638 | 639 | ): |
|
639 | 640 | '''Spawn a command without waiting for it to finish.''' |
|
640 | 641 | # we can't use close_fds *and* redirect stdin. I'm not sure that we |
|
641 | 642 | # need to because the detached process has no console connection. |
|
642 | p = subprocess.Popen( | |
|
643 | tonativestr(script), | |
|
644 | shell=shell, | |
|
645 | env=tonativeenv(env), | |
|
646 | close_fds=True, | |
|
647 | creationflags=_creationflags, | |
|
648 |
|
|
|
649 |
|
|
|
650 | ) | |
|
651 | if record_wait is not None: | |
|
652 | record_wait(p.wait) | |
|
643 | ||
|
644 | try: | |
|
645 | stdin = None | |
|
646 | if stdin_bytes is not None: | |
|
647 | stdin = pycompat.unnamedtempfile() | |
|
648 | stdin.write(stdin_bytes) | |
|
649 | stdin.flush() | |
|
650 | stdin.seek(0) | |
|
651 | ||
|
652 | p = subprocess.Popen( | |
|
653 | tonativestr(script), | |
|
654 | shell=shell, | |
|
655 | env=tonativeenv(env), | |
|
656 | close_fds=True, | |
|
657 | creationflags=_creationflags, | |
|
658 | stdin=stdin, | |
|
659 | stdout=stdout, | |
|
660 | stderr=stderr, | |
|
661 | ) | |
|
662 | if record_wait is not None: | |
|
663 | record_wait(p.wait) | |
|
664 | finally: | |
|
665 | if stdin is not None: | |
|
666 | stdin.close() | |
|
653 | 667 | |
|
654 | 668 | |
|
655 | 669 | else: |
@@ -662,6 +676,7 b' else:' | |||
|
662 | 676 | stderr=None, |
|
663 | 677 | ensurestart=True, |
|
664 | 678 | record_wait=None, |
|
679 | stdin_bytes=None, | |
|
665 | 680 | ): |
|
666 | 681 | '''Spawn a command without waiting for it to finish. |
|
667 | 682 | |
@@ -722,15 +737,21 b' else:' | |||
|
722 | 737 | if record_wait is None: |
|
723 | 738 | # Start a new session |
|
724 | 739 | os.setsid() |
|
740 | # connect stdin to devnull to make sure the subprocess can't | |
|
741 | # muck up that stream for mercurial. | |
|
742 | if stdin_bytes is None: | |
|
743 | stdin = open(os.devnull, b'r') | |
|
744 | else: | |
|
745 | stdin = pycompat.unnamedtempfile() | |
|
746 | stdin.write(stdin_bytes) | |
|
747 | stdin.flush() | |
|
748 | stdin.seek(0) | |
|
725 | 749 | |
|
726 | stdin = open(os.devnull, b'r') | |
|
727 | 750 | if stdout is None: |
|
728 | 751 | stdout = open(os.devnull, b'w') |
|
729 | 752 | if stderr is None: |
|
730 | 753 | stderr = open(os.devnull, b'w') |
|
731 | 754 | |
|
732 | # connect stdin to devnull to make sure the subprocess can't | |
|
733 | # muck up that stream for mercurial. | |
|
734 | 755 | p = subprocess.Popen( |
|
735 | 756 | cmd, |
|
736 | 757 | shell=shell, |
@@ -754,5 +775,6 b' else:' | |||
|
754 | 775 | finally: |
|
755 | 776 | # mission accomplished, this child needs to exit and not |
|
756 | 777 | # continue the hg process here. |
|
778 | stdin.close() | |
|
757 | 779 | if record_wait is None: |
|
758 | 780 | os._exit(returncode) |
General Comments 0
You need to be logged in to leave comments.
Login now