Close fds in RunCommand to prevent children from inheriting file handles.

RunCommand should only pass in stdin, stdout, and stderr to processes,
not other file handles. Fixing this prevents issues where child
processes can cause the parent to hang by forgetting to close the
file handle when launching daemons.

BUG=chromium-os:18104
TEST=Buildbot run with smoke suite. Unit tests.

Change-Id: Ib85095e1fb592ef05a972a5412348363049e6d86
Reviewed-on: http://gerrit.chromium.org/gerrit/4673
Reviewed-by: Brian Harring <ferringb@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Tested-by: David James <davidjames@chromium.org>
This commit is contained in:
David James 2011-07-25 13:15:11 -07:00
parent f5029789d6
commit 4e098db36f

View File

@ -95,7 +95,7 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
(GetCallerName(), cmd, cwd))
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
stdout=stdout, stderr=stderr)
stdout=stdout, stderr=stderr, close_fds=True)
(output, error) = proc.communicate(input)
# if the command worked, don't retry any more.
@ -163,7 +163,7 @@ def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None,
(GetCallerName(), cmd, cwd))
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
stdout=stdout, stderr=stderr)
stdout=stdout, stderr=stderr, close_fds=True)
output, error = proc.communicate(input)
if verbose: