From 4e098db36fd1878039c05fbfb3c11d1d90192550 Mon Sep 17 00:00:00 2001 From: David James Date: Mon, 25 Jul 2011 13:15:11 -0700 Subject: [PATCH] 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 Reviewed-by: Don Garrett Tested-by: David James --- lib/cros_build_lib.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py index 5a1c0d2e77..68de31db31 100644 --- a/lib/cros_build_lib.py +++ b/lib/cros_build_lib.py @@ -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: