diff options
author | Ying Wang <wangying@google.com> | 2010-12-13 16:25:36 -0800 |
---|---|---|
committer | Ying Wang <wangying@google.com> | 2010-12-13 16:25:36 -0800 |
commit | f9bbfb577233bce7bb9a0ab7ec842074ce59e6e7 (patch) | |
tree | ff3f297231ff945b9c6eac255654ccee8750bef1 /tools | |
parent | 2fd81cf11e3ebc8550f6ceee9328c5cb021b9619 (diff) | |
download | build-f9bbfb577233bce7bb9a0ab7ec842074ce59e6e7.zip build-f9bbfb577233bce7bb9a0ab7ec842074ce59e6e7.tar.gz build-f9bbfb577233bce7bb9a0ab7ec842074ce59e6e7.tar.bz2 |
Close inherited PIPE before doing work
Gmake in Darwin has file descriptor leak.
In a full build, ota_from_target_files will inherits
more than 2000 open PIPEs from gmake and fails in a call to select.select().
This change fixes the build by closing the PIPEs before doing real work.
Change-Id: Ife021382198642a97bbbf0b623e4f24f3d86b2b2
Diffstat (limited to 'tools')
-rw-r--r-- | tools/releasetools/common.py | 17 | ||||
-rwxr-xr-x | tools/releasetools/img_from_target_files | 1 | ||||
-rwxr-xr-x | tools/releasetools/ota_from_target_files | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py index a236a12..ac1566b 100644 --- a/tools/releasetools/common.py +++ b/tools/releasetools/common.py @@ -18,6 +18,7 @@ import getopt import getpass import imp import os +import platform import re import sha import shutil @@ -57,6 +58,22 @@ def Run(args, **kwargs): return subprocess.Popen(args, **kwargs) +def CloseInheritedPipes(): + """ Gmake in MAC OS has file descriptor (PIPE) leak. We close those fds + before doing other work.""" + if platform.system() != "Darwin": + return + for d in range(3, 1025): + try: + stat = os.fstat(d) + if stat is not None: + pipebit = stat[0] & 0x1000 + if pipebit != 0: + os.close(d) + except OSError: + pass + + def LoadInfoDict(zip): """Read and parse the META/misc_info.txt key/value pairs from the input target files and return a dict.""" diff --git a/tools/releasetools/img_from_target_files b/tools/releasetools/img_from_target_files index f10af49..78fd141 100755 --- a/tools/releasetools/img_from_target_files +++ b/tools/releasetools/img_from_target_files @@ -181,6 +181,7 @@ def main(argv): if __name__ == '__main__': try: + common.CloseInheritedPipes() main(sys.argv[1:]) except common.ExternalError, e: print diff --git a/tools/releasetools/ota_from_target_files b/tools/releasetools/ota_from_target_files index aa691b4..cd10d7c 100755 --- a/tools/releasetools/ota_from_target_files +++ b/tools/releasetools/ota_from_target_files @@ -781,6 +781,7 @@ def main(argv): if __name__ == '__main__': try: + common.CloseInheritedPipes() main(sys.argv[1:]) except common.ExternalError, e: print |