Prevent CMD windows being shown when starting git in a subprocess. · gitpython-developers/GitPython@0d93908

Original file line numberDiff line numberDiff line change

@@ -609,6 +609,12 @@ def execute(self, command,

609609

# end handle

610610
611611

try:

612+

if sys.platform == 'win32':

613+

CREATE_NO_WINDOW = 0x08000000

614+

creationflags = CREATE_NO_WINDOW

615+

else:

616+

creationflags = None

617+
612618

proc = Popen(command,

613619

env=env,

614620

cwd=cwd,

@@ -619,6 +625,7 @@ def execute(self, command,

619625

shell=self.USE_SHELL,

620626

close_fds=(os.name == 'posix'), # unsupported on windows

621627

universal_newlines=universal_newlines,

628+

creationflags=creationflags,

622629

**subprocess_kwargs

623630

)

624631

except cmd_not_found_exception as err:

@@ -629,7 +636,13 @@ def execute(self, command,

629636
630637

def _kill_process(pid):

631638

""" Callback method to kill a process. """

632-

p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE)

639+

if sys.platform == 'win32':

640+

CREATE_NO_WINDOW = 0x08000000

641+

creationflags = CREATE_NO_WINDOW

642+

else:

643+

creationflags = None

644+
645+

p = Popen(['ps', '--ppid', str(pid)], stdout=PIPE, creationflags)

633646

child_pids = []

634647

for line in p.stdout:

635648

if len(line.split()) > 0: