From c6dd816cb6f09cb0148730875f02018b4949e9b6 Mon Sep 17 00:00:00 2001 From: Alessandro Pilotti Date: Fri, 9 Nov 2012 20:06:31 +0200 Subject: Fixes a bug in nova.utils, due to Windows compatibility issues. Fixes Bug #1077121 subprocess.Popen() does not support preexec_fn and close_fds = True on Windows Change-Id: I69697b692b982c7cf786f52cc57f95b4819b50d8 --- nova/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nova/utils.py b/nova/utils.py index d9ded16b6..5f78b93da 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -180,12 +180,20 @@ def execute(*cmd, **kwargs): try: LOG.debug(_('Running cmd (subprocess): %s'), ' '.join(cmd)) _PIPE = subprocess.PIPE # pylint: disable=E1101 + + if os.name == 'nt': + preexec_fn = None + close_fds = False + else: + preexec_fn = _subprocess_setup + close_fds = True + obj = subprocess.Popen(cmd, stdin=_PIPE, stdout=_PIPE, stderr=_PIPE, - close_fds=True, - preexec_fn=_subprocess_setup, + close_fds=close_fds, + preexec_fn=preexec_fn, shell=shell) result = None if process_input is not None: -- cgit