Skip to content

Commit fa315b2

Browse files
authored
Update exec_cmd
1 parent a060e0c commit fa315b2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pyggi/base/program.py

+6
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ def exec_cmd(self, cmd, timeout=15):
269269
kwargs = {}
270270
if os.name == 'posix':
271271
kwargs['preexec_fn'] = os.setsid
272+
elif os.name == 'nt':
273+
kwargs['creationflags'] = subprocess.CREATE_NEW_PROCESS_GROUP
274+
else:
275+
raise Exception("Unsupported OS")
276+
272277
sprocess = subprocess.Popen(
273278
shlex.split(cmd),
274279
stdout=subprocess.PIPE,
@@ -283,6 +288,7 @@ def exec_cmd(self, cmd, timeout=15):
283288
if os.name == 'posix':
284289
os.killpg(os.getpgid(sprocess.pid), signal.SIGKILL)
285290
else:
291+
sprocess.send_signal(signal.CTRL_BREAK_EVENT)
286292
sprocess.kill()
287293
_, _ = sprocess.communicate()
288294
return (None, None, None, None)

0 commit comments

Comments
 (0)