# HG changeset patch # User Doug Simon # Date 1421863246 -3600 # Node ID d199e643f23b24c1018b4a28ae7743a5eca04c2c # Parent 16ffeae587729ead3d5f0bbcbded5c8a8da3a150 mx: replaced MX_SUBPROCESS_COMMAND with MX_SUBPROCESS_COMMAND_FILE diff -r 16ffeae58772 -r d199e643f23b graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java --- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Tue Jan 20 23:18:17 2015 +0100 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Wed Jan 21 19:00:46 2015 +0100 @@ -23,6 +23,7 @@ package com.oracle.graal.test; import java.io.*; +import java.nio.file.*; import java.util.*; import junit.runner.*; @@ -167,6 +168,23 @@ } /** + * Gets the command line for the current process. + * + * @return the command line arguments for the current process or {@code null} if they are not + * available + */ + public static List getProcessCommandLine() { + String processArgsFile = System.getenv().get("MX_SUBPROCESS_COMMAND_FILE"); + if (processArgsFile != null) { + try { + return Files.readAllLines(new File(processArgsFile).toPath()); + } catch (IOException e) { + } + } + return null; + } + + /** * Expand any arguments starting with @ and return the resulting argument array. * * @param args diff -r 16ffeae58772 -r d199e643f23b mxtool/mx.py --- a/mxtool/mx.py Tue Jan 20 23:18:17 2015 +0100 +++ b/mxtool/mx.py Wed Jan 21 19:00:46 2015 +0100 @@ -1868,9 +1868,19 @@ assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) if env is None: - env = os.environ - - env['MX_SUBPROCESS_COMMAND'] = '|'.join(args) + env = os.environ.copy() + + # Ideally the command line could be communicated directly in an environment + # variable. However, since environment variables share the same resource + # space as the command line itself (on Unix at least), this would cause the + # limit to be exceeded too easily. + _, subprocessCommandFile = tempfile.mkstemp(suffix='', prefix='mx_subprocess_command.') + with open(subprocessCommandFile, 'w') as fp: + for arg in args: + # TODO: handle newlines in args once there's a use case + assert '\n' not in arg + print >> fp, arg + env['MX_SUBPROCESS_COMMAND_FILE'] = subprocessCommandFile if _opts.verbose: if _opts.very_verbose: @@ -1932,6 +1942,7 @@ abort(1) finally: _removeSubprocess(sub) + os.remove(subprocessCommandFile) if retcode and nonZeroIsFatal: if _opts.verbose: