Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 18892:d199e643f23b
mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 21 Jan 2015 19:00:46 +0100 |
parents | 16ffeae58772 |
children | 8e8b4a6a85f5 |
comparison
equal
deleted
inserted
replaced
18891:16ffeae58772 | 18892:d199e643f23b |
---|---|
1866 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args) | 1866 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args) |
1867 for arg in args: | 1867 for arg in args: |
1868 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) | 1868 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) |
1869 | 1869 |
1870 if env is None: | 1870 if env is None: |
1871 env = os.environ | 1871 env = os.environ.copy() |
1872 | 1872 |
1873 env['MX_SUBPROCESS_COMMAND'] = '|'.join(args) | 1873 # Ideally the command line could be communicated directly in an environment |
1874 # variable. However, since environment variables share the same resource | |
1875 # space as the command line itself (on Unix at least), this would cause the | |
1876 # limit to be exceeded too easily. | |
1877 _, subprocessCommandFile = tempfile.mkstemp(suffix='', prefix='mx_subprocess_command.') | |
1878 with open(subprocessCommandFile, 'w') as fp: | |
1879 for arg in args: | |
1880 # TODO: handle newlines in args once there's a use case | |
1881 assert '\n' not in arg | |
1882 print >> fp, arg | |
1883 env['MX_SUBPROCESS_COMMAND_FILE'] = subprocessCommandFile | |
1874 | 1884 |
1875 if _opts.verbose: | 1885 if _opts.verbose: |
1876 if _opts.very_verbose: | 1886 if _opts.very_verbose: |
1877 log('Environment variables:') | 1887 log('Environment variables:') |
1878 for key in sorted(env.keys()): | 1888 for key in sorted(env.keys()): |
1930 abort(e.errno) | 1940 abort(e.errno) |
1931 except KeyboardInterrupt: | 1941 except KeyboardInterrupt: |
1932 abort(1) | 1942 abort(1) |
1933 finally: | 1943 finally: |
1934 _removeSubprocess(sub) | 1944 _removeSubprocess(sub) |
1945 os.remove(subprocessCommandFile) | |
1935 | 1946 |
1936 if retcode and nonZeroIsFatal: | 1947 if retcode and nonZeroIsFatal: |
1937 if _opts.verbose: | 1948 if _opts.verbose: |
1938 if _opts.very_verbose: | 1949 if _opts.very_verbose: |
1939 raise subprocess.CalledProcessError(retcode, ' '.join(args)) | 1950 raise subprocess.CalledProcessError(retcode, ' '.join(args)) |